sqlquery

package module
v0.0.0-...-b0b21a8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 24, 2022 License: BSD-3-Clause Imports: 7 Imported by: 0

README

SQLQuery Database Activity

This activity provides your flogo application execute database queries.

Installation

flogo install github.com/project-flogo/activity/sqlquery

Configuration

Settings:
Name Type Description
dbType string The type of database (mysql, oracle, postgres, sqlite, sqlserver) - REQUIRED
driverName string The database driver name - REQUIRED
dataSourceName string The database DataSource name - REQUIRED
maxOpenConnections int Max open connections (default is unlimited)
maxIdleConnections int Max idle connections (default is 2)
query string The SQL select query - REQUIRED
disablePrepared bool Disable prepared statement usage
labeledResults bool Return results labeled by column name
Input:
Name Type Description
params map The query parameters
Output:
Name Type Description
columnNames array The names of the result columns
results array The results

Examples

Query

Simple query that gets all items with ID less than 10, retrieves all the columns. In order to use mysql, you have to import the driver by adding github.com/go-sql-driver/mysql to the app imports section. See github.com/go-sql-driver/mysql for more information on the driver.

{
  "id": "dbquery",
  "name": "DbQuery",
  "activity": {
    "ref": "github.com/TNTworks/flogo-contrib/activity/sqlquery",
    "settings": {
      "dbType": "mysql",
      "driverName": "mysql",
      "dataSourceName": "username:password@tcp(host:port)/dbName",
      "query": "select * from test where ID < 10"
    }
  }
}
Named Query

Query with parameters. Parameters are referenced using ':', e.g. :id, regardless of database

{
  "id": "named_dbquery",
  "name": "Named DbQuery",
  "activity": {
    "ref": "github.com/TNTworks/flogo-contrib/activity/sqlquery",
    "settings": {
      "dbType": "mysql",
      "driverName": "mysql",
      "dataSourceName": "username:password@tcp(host:port)/dbName",
      "query": "select * from test where ID < :id"
    },
    "input": {
      "params": {
        "id":10
      }
    }
  }
}
Supported Drivers

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

Types

type Activity

type Activity struct {
	// contains filtered or unexported fields
}

Activity is a Counter Activity implementation

func (*Activity) Cleanup

func (a *Activity) Cleanup() error

func (*Activity) Eval

func (a *Activity) Eval(ctx activity.Context) (done bool, err error)

Eval implements activity.Activity.Eval

func (*Activity) Metadata

func (a *Activity) Metadata() *activity.Metadata

Metadata implements activity.Activity.Metadata

type Input

type Input struct {
	Params map[string]interface{} `md:"params"`
}

func (*Input) FromMap

func (i *Input) FromMap(values map[string]interface{}) error

FromMap converts the values from a map into the struct Input

func (*Input) ToMap

func (i *Input) ToMap() map[string]interface{}

ToMap converts the struct Input into a map

type Output

type Output struct {
	ColumnNames []interface{} `md:"columnNames"`
	Results     interface{}   `md:"results"`
}

type Settings

type Settings struct {
	DbType          string `md:"dbType,allowed(mysql,oracle,postgres,sqlite,sqlserver), required"`
	DriverName      string `md:"driverName,required"`
	DataSourceName  string `md:"dataSourceName,required"`
	Query           string `md:"query,required"`
	MaxOpenConns    int    `md:"maxOpenConnections"`
	MaxIdleConns    int    `md:"maxIdleConnections"`
	DisablePrepared bool   `md:"disablePrepared"`
	LabeledResults  bool   `md:"labeledResults"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL