added sql server to sql docs, resolves #1047
parent
db5ecff506
commit
1d9dbc8369
|
@ -4,7 +4,8 @@ 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, MySQL, Snowflake, and SQLite.
|
||||
Use `sql.from()` to query SQL databases like PostgreSQL, MySQL, Snowflake,
|
||||
SQLite, and MS SQL Server.
|
||||
v2.0/tags: [query, flux, sql]
|
||||
menu:
|
||||
v2_0:
|
||||
|
@ -30,7 +31,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/),
|
||||
[Snowflake](https://www.snowflake.com/), and [SQLite](https://www.sqlite.org/index.html),
|
||||
[Snowflake](https://www.snowflake.com/), [SQLite](https://www.sqlite.org/index.html),
|
||||
and [MS SQL Server](https://www.microsoft.com/en-us/sql-server/default.aspx),
|
||||
and use the results with InfluxDB dashboards, tasks, and other operations.
|
||||
|
||||
- [Query a SQL data source](#query-a-sql-data-source)
|
||||
|
@ -57,6 +59,7 @@ To query a SQL data source:
|
|||
[MySQL](#)
|
||||
[Snowflake](#)
|
||||
[SQLite](#)
|
||||
[SQL Server](#)
|
||||
{{% /code-tabs %}}
|
||||
|
||||
{{% code-tab-content %}}
|
||||
|
@ -110,6 +113,16 @@ sql.from(
|
|||
)
|
||||
```
|
||||
{{% /code-tab-content %}}
|
||||
|
||||
{{% code-tab-content %}}
|
||||
```js
|
||||
sql.from(
|
||||
driverName: "sqlserver",
|
||||
dataSourceName: "sqlserver://user:password@localhost:1234?database=examplebdb",
|
||||
query: "GO SELECT * FROM Example.Table"
|
||||
)
|
||||
```
|
||||
{{% /code-tab-content %}}
|
||||
{{< /code-tabs-wrapper >}}
|
||||
|
||||
_See the [`sql.from()` documentation](/v2.0/reference/flux/stdlib/sql/from/) for
|
||||
|
|
|
@ -3,7 +3,7 @@ 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, PostgreSQL, and SQLite.
|
||||
as MySQL, PostgreSQL, Snowflake, SQLite, and MS SQL Server.
|
||||
Import the `sql` package.
|
||||
aliases:
|
||||
- /v2.0/reference/flux/functions/sql/
|
||||
|
@ -18,7 +18,7 @@ related:
|
|||
---
|
||||
|
||||
SQL Flux functions provide tools for working with data in SQL databases such as
|
||||
MySQL, PostgreSQL, Snowflake, and SQLite.
|
||||
MySQL, PostgreSQL, Snowflake, SQLite, and MS SQL Server.
|
||||
Import the `sql` package:
|
||||
|
||||
```js
|
||||
|
|
|
@ -39,6 +39,7 @@ The following drivers are available:
|
|||
- postgres
|
||||
- snowflake
|
||||
- sqlite3 – _Does not work with InfluxDB OSS or InfluxDB Cloud. More information [below](#query-an-sqlite-database)._
|
||||
- sqlserver, mssql
|
||||
|
||||
### dataSourceName
|
||||
The data source name (DSN) or connection string used to connect to the SQL database.
|
||||
|
@ -61,6 +62,12 @@ username[:password]@hostname:port/dbname/schemaname?account=<your_account>¶m
|
|||
|
||||
# SQLite Driver DSN
|
||||
file:/path/to/test.db?cache=shared&mode=ro
|
||||
|
||||
# MS SQL Server Driver DSNs
|
||||
sqlserver://username:password@localhost:1234?database=examplebdb
|
||||
server=localhost;user id=username;database=examplebdb;
|
||||
server=localhost;user id=username;database=examplebdb;azure auth=ENV
|
||||
server=localhost;user id=username;database=examplebdbr;azure tenant id=77e7d537;azure client id=58879ce8;azure client secret=0123456789
|
||||
```
|
||||
|
||||
### query
|
||||
|
@ -139,3 +146,18 @@ sql.from(
|
|||
query: "SELECT * FROM example_table"
|
||||
)
|
||||
```
|
||||
|
||||
### Query a SQL Server database
|
||||
```js
|
||||
import "sql"
|
||||
import "influxdata/influxdb/secrets"
|
||||
|
||||
username = secrets.get(key: "SQLSERVER_USER")
|
||||
password = secrets.get(key: "SQLSERVER_PASS")
|
||||
|
||||
sql.from(
|
||||
driverName: "sqlserver",
|
||||
dataSourceName: "sqlserver://${username}:${password}@localhost:1234?database=examplebdb",
|
||||
query: "GO SELECT * FROM Example.Table"
|
||||
)
|
||||
```
|
||||
|
|
|
@ -38,6 +38,7 @@ The following drivers are available:
|
|||
- postgres
|
||||
- snowflake
|
||||
- sqlite3 – _Does not work with InfluxDB OSS or InfluxDB Cloud. More information [below](#write-data-to-an-sqlite-database)._
|
||||
- sqlserver, mssql
|
||||
|
||||
### dataSourceName
|
||||
The data source name (DSN) or connection string used to connect to the SQL database.
|
||||
|
@ -60,6 +61,12 @@ username[:password]@hostname:port/dbname/schemaname?account=<your_account>¶m
|
|||
|
||||
# SQLite Driver DSN
|
||||
file:/path/to/test.db?cache=shared&mode=rw
|
||||
|
||||
# MS SQL Server Driver DSNs
|
||||
sqlserver://username:password@localhost:1234?database=examplebdb
|
||||
server=localhost;user id=username;database=examplebdb;
|
||||
server=localhost;user id=username;database=examplebdb;azure auth=ENV
|
||||
server=localhost;user id=username;database=examplebdbr;azure tenant id=77e7d537;azure client id=58879ce8;azure client secret=0123456789
|
||||
```
|
||||
|
||||
### table
|
||||
|
@ -148,3 +155,18 @@ sql.to(
|
|||
table: "example_table"
|
||||
)
|
||||
```
|
||||
|
||||
### Write data to a SQL Server database
|
||||
```js
|
||||
import "sql"
|
||||
import "influxdata/influxdb/secrets"
|
||||
|
||||
username = secrets.get(key: "SQLSERVER_USER")
|
||||
password = secrets.get(key: "SQLSERVER_PASS")
|
||||
|
||||
sql.to(
|
||||
driverName: "sqlserver",
|
||||
dataSourceName: "sqlserver://${username}:${password}@localhost:1234?database=examplebdb",
|
||||
table: "Example.Table"
|
||||
)
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue