3.2.0 • Published 8 months ago

@runnerty/executor-mysql v3.2.0

Weekly downloads
96
License
MIT
Repository
github
Last release
8 months ago

NPM version Downloads

MySQL executor for Runnerty:

Installation:

Through NPM

npm i @runnerty/executor-mysql

You can also add modules to your project with runnerty

npx runnerty add @runnerty/executor-mysql

This command installs the module in your project, adds example configuration in your config.json and creates an example plan of use.

If you have installed runnerty globally you can include the module with this command:

runnerty add @runnerty/executor-mysql

Configuration:

Add in config.json:

{
  "id": "mysql_default",
  "type": "@runnerty-executor-mysql",
  "user": "mysqlusr",
  "password": "mysqlpass",
  "database": "MYDB",
  "host": "myhost.com",
  "port": "3306"
}
{
  "id": "mysql_default",
  "type": "@runnerty-executor-mysql",
  "user": "mysqlusr",
  "password": "mysqlpass",
  "database": "MYDB",
  "host": "myhost.com",
  "port": "3306",
  "ssl": {
    "ca": "./ssl/my.ca"
  }
}

Configuration params:

ParameterDescription
userThe MySQL user to authenticate as.
passwordThe password of that MySQL user.
databaseName of the database to use for this connection. (Optional)
hostThe hostname of the database you are connecting to.
portThe port number to connect to. (Default: 3306)
socketPathThe path to a unix domain socket to connect to. When used host and port are ignored. (Optional)
charsetThe charset for the connection (collation). (Default: 'UTF8_GENERAL_CI')
timezoneThe timezone configured on the MySQL server. (Default: 'local')
insecureAuthAllow connecting to MySQL instances that ask for the old (insecure) authentication method. (Default: false)
flagsConnection flags. More information here.
multipleStatementsAllow multiple mysql statements per query. (Default: true)
ssl/caSSL CA File (Optional)
ssl/certSSL CERT File (Optional)
ssl/keySSL KEY File (Optional)

Plan sample:

Add in plan.json:

{
  "id": "mysql_default",
  "command_file": "/etc/runnerty/sql/test.sql"
}
{
  "id": "mysql_default",
  "command": "SELECT NOW()"
}

Generation of files:

The saved can be indicated in the file of the results obtained from a query in csv, xlsx and json format. These files will be generated with streams. You only have to indicate the corresponding property in the parameters:

XLSX

XLSX Format

ParameterDescription
xlsxFileExportPath of xlsx file export.
xlsxAuthorNameAuthor file name. (Optional)
xlsxSheetNameName of the sheet. (Optional)

Sample:

{
  "id": "mysql_sample",
  "command": "SELECT * FROM USERS",
  "xlsxFileExport": "./my_output.xlsx",
  "xlsxAuthorName": "Runnerty",
  "xlsxSheetName": "MySheetSample"
}

CSV

CSV Format

ParameterDescription
csvFileExportPath of csv file export.
csvOptions/headersType: boolean/string[]. The headers will be auto detected from the first row or you can to provide headers array: 'h1name','h2name',....
csvOptions/delimiterAlternate delimiter. (Default: ',')
csvOptions/quoteAlternate quote. (Default: '"')
csvOptions/alwaysWriteHeadersSet to true if you always want headers written, even if no rows are written. (Default: false)
csvOptions/rowDelimiterSpecify an alternate row delimiter (i.e \r\n). (Default: '\n')
csvOptions/quoteHeadersIf true then all headers will be quoted. (Default: quoteColumns value)
csvOptions/quoteColumnsIf true then columns and headers will be quoted (unless quoteHeaders is specified). (Default: false). More info here.
csvOptions/escapeAlternate escaping value. (Default: '"')
csvOptions/includeEndRowDelimiterSet to true to include a row delimiter at the end of the csv. (Default: false)
csvOptions/writeBOMSet to true if you want the first character written to the stream to be a utf-8 BOM character. (Default: false)

Sample:

{
  "id": "mysql_sample",
  "command": "SELECT * FROM USERS",
  "csvFileExport": "@GV(WORK_DIR)/users.csv",
  "csvOptions": {
    "delimiter": ";",
    "quote": "\""
  }
}

JSON

JSON Format

Sample:

{
  "id": "mysql_sample",
  "command": "SELECT * FROM USERS",
  "fileExport": "@GV(WORK_DIR)/users.json"
}

Loading files:

For file upload you must indicate the path of the file to be loaded in the localInFile parameter and in the LOAD DATA LOCAL INFILE statement you must indicate mystream. For example:

  • localInFile: Plain file path
{
  "id": "mysql_sample",
  "command": "LOAD DATA LOCAL INFILE 'mystream' INTO TABLE DBSAMPLE.TABLESAMPLE FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n'",
  "localInFile": "/sample.csv"
}

Output (Process values):

Standard

  • PROCESS_EXEC_MSG_OUTPUT: MySQL output message.
  • PROCESS_EXEC_ERR_OUTPUT: Error output message.

Query output

  • PROCESS_EXEC_DATA_OUTPUT: MySQL query output data.
  • PROCESS_EXEC_DB_COUNTROWS: MySQL query count rows.
  • PROCESS_EXEC_DB_FIRSTROW: MySQL query first row data.
  • PROCESS_EXEC_DB_FIRSTROW_[FILED_NAME]: MySQL first row field data.

Operation output

  • PROCESS_EXEC_DB_FIELDCOUNT: MySQL field count.
  • PROCESS_EXEC_DB_AFFECTEDROWS: MySQL affected rows count.
  • PROCESS_EXEC_DB_CHANGEDROWS: MySQL changed rows count.
  • PROCESS_EXEC_DB_INSERTID: MySQL insert ID.
  • PROCESS_EXEC_DB_WARNINGCOUNT: MySQL warning count.
  • PROCESS_EXEC_DB_MESSAGE: MySQL message.
3.2.0

8 months ago

3.1.3

1 year ago

3.1.4

1 year ago

3.1.1

2 years ago

3.0.10

2 years ago

3.0.11

2 years ago

3.1.0

2 years ago

3.0.9

3 years ago

3.0.8

3 years ago

3.0.7

3 years ago

3.0.6

3 years ago

3.0.5

3 years ago

3.0.4

3 years ago

3.0.3

3 years ago

3.0.2

3 years ago

3.0.1

3 years ago

3.0.0

3 years ago

2.1.6

3 years ago

2.1.5

3 years ago

2.1.4

3 years ago

2.1.3

4 years ago

2.1.2

4 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.1.0-rc2

4 years ago

2.1.0-rc

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.1-rc1

4 years ago

2.0.1-rc

4 years ago

2.0.0

4 years ago

2.0.0-rc3

4 years ago

2.0.0-rc2

4 years ago

2.0.0-rc1

4 years ago

2.0.0-rc0

4 years ago

1.1.5

5 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.4

6 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago