/usql

Usql client for Direktiv

Primary LanguageGoApache License 2.0Apache-2.0

usql 1.0.0

Usql client for Direktiv



About usql

Usql is a universal command-line interface for PostgreSQL, MySQL, Oracle Database, SQLite3, Microsoft SQL Server, and many other databases including NoSQL and non-relational databases. This service provides easy access to database from Direktiv and supports variables and interpolation as well.

Example(s)

Function Configuration

functions:
- id: usql
  image: direktiv/usql
  type: knative-workflow

Basic

- id: insert 
  type: action
  action:
    function: usql
    input:
      connection: pg://direktiv:rbRIw3I6%7B5%29%5Dda%287m.R_%5D%3Eh%5D@192.168.0.177:5432
      queries:
        - query: select * from mydata

Variables

- id: insert 
  type: action
  action:
    function: usql
    input:
      connection: pg://direktiv:rbRIw3I6%7B5%29%5Dda%287m.R_%5D%3Eh%5D@192.168.0.177:5432
      queries:
        - query: select * from mydata where id = :'ID'
          args:
          - ID=3a7ff4a5-fadb-4d41-97bb-86917cdad46a

Insert

- id: insert 
  type: action
  action:
    function: usql
    input:
      connection: pg://direktiv:rbRIw3I6%7B5%29%5Dda%287m.R_%5D%3Eh%5D@192.168.0.177:5432
      queries:
        - query: insert into testme values ('hello world')

Request

Request Attributes

PostParamsBody

Response

The service responds with one JSON payload per SQL query.

Reponse Types

PostOKBody

Example Reponses

{
  "queries": [
    {
      "result": [
        {
          "id": "c5c20864-2c1b-47e2-94ab-185a3e8cf9ee",
          "name": 123
        }
      ],
      "success": true
    },
    {
      "result": "INSERT 1",
      "success": true
    }
  ]
}

Errors

Type Description
io.direktiv.command.error Command execution failed
io.direktiv.output.error Template error for output generation of the service
io.direktiv.ri.error Can not create information object from request

Types

postOKBody

Properties

Name Type Go type Required Default Description Example
queries []PostOKBodyQueriesItems []*PostOKBodyQueriesItems

postOKBodyQueriesItems

Properties

Name Type Go type Required Default Description Example
result interface{} interface{}
success boolean bool

postParamsBody

Properties

Name Type Go type Required Default Description Example
connection string string Connection string for sql commands. This will be used for all commands and has to be URL-encoded. pg://myuser:mypwd@MYDATABAESERVER:5432
queries []PostParamsBodyQueriesItems []*PostParamsBodyQueriesItems List of sql commands. Commands can use interpolation:
query: select * from table where id = :'ID'
args: ID=123
{"args":["KEY=1"],"query":"select * from mytable where key = :'KEY'"}

postParamsBodyQueriesItems

Properties

Name Type Go type Required Default Description Example
args []string []string ARG=myarg
query string string select * from table where value = :'ARG'