Documentation

sql 包

sql 包提供了用于在 SQL 数据库中处理数据的工具。导入 sql 包:

import "sql"

SQL 数据源名称

sql 包使用 Go 驱动程序连接到 SQL 数据库。数据源名称(DSN)(也称为连接字符串)由所使用的驱动程序确定。

# Amazon Athena Driver DSN
s3://myorgqueryresults/?accessID=AKIAJLO3F...&region=us-west-1&secretAccessKey=NnQ7MUMp9PYZsmD47c%2BSsXGOFsd%2F...
s3://myorgqueryresults/?accessID=AKIAJLO3F...&db=dbname&missingAsDefault=false&missingAsEmptyString=false&region=us-west-1&secretAccessKey=NnQ7MUMp9PYZsmD47c%2BSsXGOFsd%2F...&WGRemoteCreation=false

# MySQL Driver DSN
username:password@tcp(localhost:3306)/dbname?param=value

# Postgres Driver DSN
postgres://pqgotest:password@localhost/pqgotest?sslmode=verify-full

# 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

# Microsoft 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

# Google BigQuery DSNs
bigquery://projectid/?param1=value&param2=value
bigquery://projectid/location?param1=value&param2=value

# SAP HANA driver DSN
hdb://<user>:<password>@<host>:<port>?<connection-property>=<value>&<connection-property>=<value>&...
hdb://<user>:<password>@<host>:<port>?DATABASENAME=<tenant-db-name>
hdb://?KEY=<keyname>

# Vertica driver DSN
vertica://<user>:<password>@<host>:<port>/<database>?<queryArgs>

AWS Athena 连接字符串

要查询 Amazon Athena 数据库,请在您的 Athena S3 连接字符串 (DNS) 中使用以下查询参数:

  • region: (必填) AWS区域。
  • accessID: (必填) AWS IAM 访问 ID。
  • SecretAccessKey: (必填) AWS IAM 秘钥。
  • db: 数据库名称。
  • WGRemoteCreation: 控制工作组和标签的创建。
  • missingAsDefault: 用默认值替换缺失的数据。
  • missingAsEmptyString: 用空字符串替换缺失的数据。

常见的 BigQuery URL 参数

Flux BigQuery 实现使用 Google Cloud Go SDK。通过以下任一方法提供您的认证凭据:

  • 标识您的凭据 JSON 文件位置的 GOOGLE_APPLICATION_CREDENTIALS 环境变量。
  • 通过在您的 BigQuery DSN 中使用 credentials URL 参数来提供您的 BigQuery 凭据。

BigQuery 凭证 URL 参数

使用凭据 URL 参数在您的 BigQuery DSN 中提供您的 base-64 编码服务帐号、刷新令牌或 JSON 凭据。

BigQuery 证书 URL 参数
bigquery://projectid/?credentials=eyJ0eXBlIjoiYXV0...

SQL Server ADO 认证

使用以下方法之一提供 SQL Server 身份验证凭据作为 ActiveX 数据对象 (ADO) 连接字符串参数:

从环境变量中检索认证凭据

azure auth=ENV

从文件中获取身份验证凭据

azure auth=C:\secure\azure.auth

注意: InfluxDB OSS 和 InfluxDB Cloud 用户界面不提供对底层文件系统的访问,并且不支持从文件中读取凭据。要从文件中检索 SQL Server 凭据,请在本地机器的 Flux REPL 中执行查询。

在连接字符串中指定身份验证凭据

# 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...

在Azure虚拟机中使用托管标识

azure auth=MSI

函数



Flux的未来

Flux 正在进入维护模式。您可以像现在一样继续使用它,而无需对您的代码进行任何更改。

阅读更多

InfluxDB 3 开源版本现已公开Alpha测试

InfluxDB 3 Open Source is now available for alpha testing, licensed under MIT or Apache 2 licensing.

我们将发布两个产品作为测试版的一部分。

InfluxDB 3 核心,是我们新的开源产品。 它是一个用于时间序列和事件数据的实时数据引擎。 InfluxDB 3 企业版是建立在核心基础之上的商业版本,增加了历史查询能力、读取副本、高可用性、可扩展性和细粒度安全性。

有关如何开始的更多信息,请查看: