sql package

The sql package provides tools for working with data in SQL databases. Import the sql package:

import "sql"

SQL data source names

The sql packages uses Go drivers to connect to SQL database. The data source name (DSN) (also known as connection string) is determined by the driver used.

# Amazon Athena Driver DSN

# MySQL Driver DSN

# Postgres Driver DSN

# Snowflake Driver DSNs

# SQLite Driver DSN

# Microsoft SQL Server Driver DSNs
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

# Google BigQuery DSNs

# SAP HANA driver DSN

# Vertica driver DSN

AWS Athena connection strings

To query an Amazon Athena database, use the following query parameters in your Athena S3 connection string (DNS):

  • region: (Required) AWS region.
  • accessID: (Required) AWS IAM access ID.
  • SecretAccessKey: (Required) AWS IAM secret key.
  • db: Database name.
  • WGRemoteCreation: Controls workgroup and tag creation.
  • missingAsDefault: Replace missing data with default values.
  • missingAsEmptyString: Replace missing data with empty strings.

Common BigQuery URL parameters

The Flux BigQuery implementation uses the Google Cloud Go SDK. Provide your authentication credentials using one of the following methods:

  • The GOOGLE_APPLICATION_CREDENTIALS environment variable that identifies the location of your credential JSON file.
  • Provide your BigQuery credentials using the credentials URL parameters in your BigQuery DSN.

BigQuery credential URL parameter

Provide your base-64 encoded service account, refresh token, or JSON credentials using the credentials URL parameter in your BigQuery DSN.

BigQuery credential URL parameter

SQL Server ADO authentication

Use one of the following methods to provide SQL Server authentication credentials as ActiveX Data Objects (ADO) connection string parameters:

Retrieve authentication credentials from environment variables

azure auth=ENV

Retrieve authentication credentials from a file

azure auth=C:\secure\azure.auth

Note: InfluxDB OSS and InfluxDB Cloud user interfaces do not provide access to the underlying filesystem and do not support reading credentials from a file. To retrieve SQL Server credentials from a file, execute the query in the Flux REPL on your local machine.

Specify authentication credentials in the connection string

# Example of providing tenant ID, client ID, and client secret token
azure tenant id=77...;azure client id=58...;azure client secret=0cf123..
# Example of providing tenant ID, client ID, certificate path and certificate password
azure tenant id=77...;azure client id=58...;azure certificate path=C:\secure\...;azure certificate password=xY...
# Example of providing tenant ID, client ID, and Azure username and password
azure tenant id=77...;azure client id=58...;azure username=some@myorg;azure password=a1...

Use a managed identity in an Azure VM

azure auth=MSI


Was this page helpful?

Thank you for your feedback!

The future of Flux

Flux is going into maintenance mode. You can continue using it as you currently are without any changes to your code.

Read more