From f672a8ffe163271b52a99ead7f132fcf5de78e74 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Wed, 26 Jun 2019 15:38:41 -0600 Subject: [PATCH 1/2] added sql package documentation --- .../reference/flux/functions/sql/_index.md | 22 +++++ .../v2.0/reference/flux/functions/sql/from.md | 79 ++++++++++++++++++ .../v2.0/reference/flux/functions/sql/to.md | 80 +++++++++++++++++++ 3 files changed, 181 insertions(+) create mode 100644 content/v2.0/reference/flux/functions/sql/_index.md create mode 100644 content/v2.0/reference/flux/functions/sql/from.md create mode 100644 content/v2.0/reference/flux/functions/sql/to.md diff --git a/content/v2.0/reference/flux/functions/sql/_index.md b/content/v2.0/reference/flux/functions/sql/_index.md new file mode 100644 index 000000000..77004614c --- /dev/null +++ b/content/v2.0/reference/flux/functions/sql/_index.md @@ -0,0 +1,22 @@ +--- +title: Flux SQL package +list_title: SQL package +description: > + The Flux SQL package provides tools for working with data in SQL databases such as MySQL and PostgreSQL. + Import the `sql` package. +menu: + v2_0_ref: + name: SQL + parent: Flux packages and functions +weight: 202 +v2.0/tags: [functions, sql, package, mysql, postgres] +--- + +SQL Flux functions provide tools for working with data in SQL databases such as MySQL and PostgreSQL. +Import the `sql` package: + +```js +import "sql" +``` + +{{< children type="functions" show="pages" >}} diff --git a/content/v2.0/reference/flux/functions/sql/from.md b/content/v2.0/reference/flux/functions/sql/from.md new file mode 100644 index 000000000..12ba2ac87 --- /dev/null +++ b/content/v2.0/reference/flux/functions/sql/from.md @@ -0,0 +1,79 @@ +--- +title: sql.from() function +description: The `sql.from()` function retrieves data from a SQL data source. +menu: + v2_0_ref: + name: sql.from + parent: SQL +weight: 202 +--- + +The `sql.from()` function retrieves data from a SQL data source. + +_**Function type:** Input_ + +```js +import "sql" + +sql.from( + driverName: "postgres", + dataSourceName: "postgresql://user:password@localhost", + query:"SELECT * FROM TestTable" +) +``` + +## Parameters + +### driverName +The driver used to connect to the SQL database. + +_**Data type:** String_ + +The following drivers are available: + +- mysql +- postrges + +### dataSourceName +The connection string used to connect to the SQL database. +Its form and structure depend on the [driver](#drivername) used. + +_**Data type:** String_ + +##### Driver dataSourceName examples +```sh +# Postgres Driver: +postgres://pqgotest:password@localhost/pqgotest?sslmode=verify-full + +# MySQL Driver: +username:password@tcp(localhost:3306)/dbname?param=value +``` + +### query +The query to run against the SQL database. + +_**Data type:** String_ + +## Examples + +### Query a MySQL database +```js +import "sql" + + sql.from( + driverName: "mysql", + dataSourceName: "user:password@tcp(localhost:3306)/db", + query:"SELECT * FROM ExampleTable" + ) +``` + +### Query a Postgres database +```js +import "sql" + +sql.from( + driverName: "postgres", + dataSourceName: "postgresql://user:password@localhost", + query:"SELECT * FROM TestTable" +) +``` diff --git a/content/v2.0/reference/flux/functions/sql/to.md b/content/v2.0/reference/flux/functions/sql/to.md new file mode 100644 index 000000000..866e6907d --- /dev/null +++ b/content/v2.0/reference/flux/functions/sql/to.md @@ -0,0 +1,80 @@ +--- +title: sql.to() function +description: The `sql.to()` function writes data to an SQL database. +menu: + v2_0_ref: + name: sql.to + parent: SQL +weight: 202 +draft: true +--- + +The `sql.to()` function writes data to a SQL database. + +_**Function type:** Output_ + +```js +import "sql" + +sql.to( + driverName: "mysql", + dataSourceName: "username:password@tcp(localhost:3306)/dbname?param=value", + table: "ExampleTable" +) +``` + +## Parameters + +### driverName +The driver used to connect to the SQL database. + +_**Data type:** String_ + +The following drivers are available: + +- mysql +- postrges + +### dataSourceName +The connection string used to connect to the SQL database. +Its form and structure depend on the [driver](#drivername) used. + +_**Data type:** String_ + +##### Driver dataSourceName examples +```sh +# Postgres Driver +postgres://pqgotest:password@localhost/pqgotest?sslmode=verify-full + +# MySQL Driver +username:password@tcp(localhost:3306)/dbname?param=value +``` + +### table +The destination table. + +_**Data type:** String_ + +## Examples + +### Write data to a MySQL database +```js +import "sql" + +sql.to( + driverName: "mysql", + dataSourceName: "user:password@tcp(localhost:3306)/db", + table: "ExampleTable" +) +``` + +### Write data to a Postgres database +```js +import "sql" + +sql.to( + driverName: "postgres", + dataSourceName: "postgresql://user:password@localhost", + table: "ExampleTable" +) +``` From f75fbf23314cb602847cef7b8e63801f5bd235e2 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Thu, 27 Jun 2019 08:56:29 -0600 Subject: [PATCH 2/2] updated sql package docs with PR feedback --- content/v2.0/reference/flux/functions/sql/from.md | 4 ++-- content/v2.0/reference/flux/functions/sql/to.md | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/content/v2.0/reference/flux/functions/sql/from.md b/content/v2.0/reference/flux/functions/sql/from.md index 12ba2ac87..1af4c3063 100644 --- a/content/v2.0/reference/flux/functions/sql/from.md +++ b/content/v2.0/reference/flux/functions/sql/from.md @@ -32,11 +32,11 @@ _**Data type:** String_ The following drivers are available: - mysql -- postrges +- postgres ### dataSourceName The connection string used to connect to the SQL database. -Its form and structure depend on the [driver](#drivername) used. +The string's form and structure depend on the [driver](#drivername) used. _**Data type:** String_ diff --git a/content/v2.0/reference/flux/functions/sql/to.md b/content/v2.0/reference/flux/functions/sql/to.md index 866e6907d..9795ce2fc 100644 --- a/content/v2.0/reference/flux/functions/sql/to.md +++ b/content/v2.0/reference/flux/functions/sql/to.md @@ -1,6 +1,6 @@ --- title: sql.to() function -description: The `sql.to()` function writes data to an SQL database. +description: The `sql.to()` function writes data to a SQL database. menu: v2_0_ref: name: sql.to @@ -33,11 +33,11 @@ _**Data type:** String_ The following drivers are available: - mysql -- postrges +- postgres ### dataSourceName The connection string used to connect to the SQL database. -Its form and structure depend on the [driver](#drivername) used. +The string's form and structure depend on the [driver](#drivername) used. _**Data type:** String_