added snowflake support, resolves #894

pull/1002/head
Scott Anderson 2020-04-30 17:01:34 -06:00
parent 18a35cfc27
commit 34e0d0403f
7 changed files with 64 additions and 13 deletions

View File

@ -458,6 +458,10 @@ For details, see [Scrape data](/v2.0/write-data/scrape-data/).
For information about using the InfluxDB v2 API, `influx` CLI, and client libraries to write data,
see [Write data to InfluxDB](/v2.0/write-data/).
#### Demo data
If using **{{< cloud-name "short" >}}**, [add a demo data bucket](/v2.0/write-data/sample-data/demo-data/)
for quick, _free_ access to time series data.
### Query data
Query data using Flux, the UI, and the `influx` command line interface.

View File

@ -201,7 +201,7 @@ pgHost = secrets.get(key: "POSTGRES_HOST")
t1 = sql.from(
driverName: "postgres",
dataSourceName: "postgresql://${pgUser}:${pgPass}@${pgHost}",
query:"SELECT id, name, available FROM exampleTable"
query:"SELECT id, name, available FROM example_table"
)
t2 = from(bucket: "example-bucket")

View File

@ -221,7 +221,7 @@ pgHost = secrets.get(key: "POSTGRES_HOST")
t1 = sql.from(
driverName: "postgres",
dataSourceName: "postgresql://${pgUser}:${pgPass}@${pgHost}",
query:"SELECT id, name, available FROM exampleTable"
query:"SELECT id, name, available FROM example_table"
)
t2 = from(bucket: "example-bucket")

View File

@ -4,7 +4,7 @@ seotitle: Query SQL data sources with InfluxDB
list_title: Query SQL data
description: >
The Flux `sql` package provides functions for working with SQL data sources.
Use `sql.from()` to query SQL databases like PostgreSQL and MySQL
Use `sql.from()` to query SQL databases like PostgreSQL, MySQL, Snowflake, and SQLite.
v2.0/tags: [query, flux, sql]
menu:
v2_0:
@ -30,8 +30,8 @@ list_code_example: |
The [Flux](/v2.0/reference/flux) `sql` package provides functions for working with SQL data sources.
[`sql.from()`](/v2.0/reference/flux/stdlib/sql/from/) lets you query SQL data sources
like [PostgreSQL](https://www.postgresql.org/), [MySQL](https://www.mysql.com/),
and [SQLite](https://www.sqlite.org/index.html), and use the results with InfluxDB
dashboards, tasks, and other operations.
[Snowflake](https://www.snowflake.com/), and [SQLite](https://www.sqlite.org/index.html),
and use the results with InfluxDB dashboards, tasks, and other operations.
- [Query a SQL data source](#query-a-sql-data-source)
- [Join SQL data with data in InfluxDB](#join-sql-data-with-data-in-influxdb)
@ -54,6 +54,7 @@ To query a SQL data source:
{{% code-tabs %}}
[PostgreSQL](#)
[MySQL](#)
[Snowflake](#)
[SQLite](#)
{{% /code-tabs %}}
@ -81,6 +82,18 @@ sql.from(
```
{{% /code-tab-content %}}
{{% code-tab-content %}}
```js
import "sql"
sql.from(
driverName: "snowflake",
dataSourceName: "user:password@account/db/exampleschema?warehouse=wh",
query: "SELECT * FROM example_table"
)
```
{{% /code-tab-content %}}
{{% code-tab-content %}}
```js
// NOTE: InfluxDB OSS and InfluxDB Cloud do not have access to

View File

@ -18,7 +18,7 @@ related:
---
SQL Flux functions provide tools for working with data in SQL databases such as
MySQL, PostgreSQL, and SQLite.
MySQL, PostgreSQL, Snowflake, and SQLite.
Import the `sql` package:
```js

View File

@ -37,6 +37,7 @@ The following drivers are available:
- mysql
- postgres
- snowflake
- sqlite3 _Does not work with InfluxDB OSS or InfluxDB Cloud. More information [below](#query-an-sqlite-database)._
### dataSourceName
@ -53,6 +54,11 @@ postgres://pqgotest:password@localhost/pqgotest?sslmode=verify-full
# MySQL Driver DSN
username:password@tcp(localhost:3306)/dbname?param=value
# Snowflake Driver DSNs
username[:password]@accountname/dbname/schemaname?param1=value1&paramN=valueN
username[:password]@accountname/dbname?param1=value1&paramN=valueN
username[:password]@hostname:port/dbname/schemaname?account=<your_account>&param1=value1&paramN=valueN
# SQLite Driver DSN
file:/path/to/test.db?cache=shared&mode=ro
```
@ -71,7 +77,7 @@ import "sql"
sql.from(
driverName: "mysql",
dataSourceName: "user:password@tcp(localhost:3306)/db",
query:"SELECT * FROM ExampleTable"
query: "SELECT * FROM example_table"
)
```
@ -82,7 +88,18 @@ import "sql"
sql.from(
driverName: "postgres",
dataSourceName: "postgresql://user:password@localhost",
query:"SELECT * FROM ExampleTable"
query: "SELECT * FROM example_table"
)
```
### Query a Snowflake database
```js
import "sql"
sql.from(
driverName: "snowflake",
dataSourceName: "user:password@account/db/exampleschema?warehouse=wh",
query: "SELECT * FROM example_table"
)
```
@ -101,6 +118,6 @@ import "sql"
sql.from(
driverName: "sqlite3",
dataSourceName: "file:/path/to/test.db?cache=shared&mode=ro",
query:"SELECT * FROM ExampleTable"
query: "SELECT * FROM example_table"
)
```

View File

@ -20,7 +20,7 @@ import "sql"
sql.to(
driverName: "mysql",
dataSourceName: "username:password@tcp(localhost:3306)/dbname?param=value",
table: "ExampleTable",
table: "example_table",
batchSize: 10000
)
```
@ -36,6 +36,7 @@ The following drivers are available:
- mysql
- postgres
- snowflake
- sqlite3 _Does not work with InfluxDB OSS or InfluxDB Cloud. More information [below](#write-data-to-an-sqlite-database)._
### dataSourceName
@ -52,6 +53,11 @@ postgres://pqgotest:password@localhost/pqgotest?sslmode=verify-full
# MySQL Driver DSN
username:password@tcp(localhost:3306)/dbname?param=value
# Snowflake Driver DSNs
username[:password]@accountname/dbname/schemaname?param1=value1&paramN=valueN
username[:password]@accountname/dbname?param1=value1&paramN=valueN
username[:password]@hostname:port/dbname/schemaname?account=<your_account>&param1=value1&paramN=valueN
# SQLite Driver DSN
file:/path/to/test.db?cache=shared&mode=rw
```
@ -80,7 +86,7 @@ import "sql"
sql.to(
driverName: "mysql",
dataSourceName: "user:password@tcp(localhost:3306)/db",
table: "ExampleTable"
table: "example_table"
)
```
@ -91,7 +97,18 @@ import "sql"
sql.to(
driverName: "postgres",
dataSourceName: "postgresql://user:password@localhost",
table: "ExampleTable"
table: "example_table"
)
```
### Write data to a Snowflake database
```js
import "sql"
sql.to(
driverName: "snowflake",
dataSourceName: "user:password@account/db/exampleschema?warehouse=wh",
table: "example_table"
)
```
@ -110,6 +127,6 @@ import "sql"
sql.to(
driverName: "sqlite3",
dataSourceName: "file:/path/to/test.db?cache=shared&mode=rw",
table: "ExampleTable"
table: "example_table"
)
```