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..1af4c3063 --- /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 +- postgres + +### dataSourceName +The connection string used to connect to the SQL database. +The string's 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..9795ce2fc --- /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 a 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 +- postgres + +### dataSourceName +The connection string used to connect to the SQL database. +The string's 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" +) +``` diff --git a/content/v2.0/reference/flux/release-notes.md b/content/v2.0/reference/flux/release-notes.md index e772b0c11..b516385cb 100644 --- a/content/v2.0/reference/flux/release-notes.md +++ b/content/v2.0/reference/flux/release-notes.md @@ -9,11 +9,25 @@ menu: --- {{% note %}} -_The latest release of InfluxDB v2.0 alpha includes **Flux v0.33.2**. +_The latest release of InfluxDB v2.0 alpha includes **Flux v0.34.1**. Though newer versions of Flux may be available, they will not be included with InfluxDB until the next InfluxDB v2.0 release._ {{% /note %}} +## v0.34.1 [2019-06-26] + +### Features +- Add custom PostgreSQL type support. +- Added MySQL type support. +- Nulls work in table and row functions. + +### Bug fixes +- Fixed boolean literal type conversion problem and added tests. +- Diff should track memory allocations when it copies the table. +- Copy table will report if it is empty correctly. + +--- + ## v0.33.2 [2019-06-25] ### Bug fixes