sql 包
sql
包提供了用于处理 SQL 数据库中数据的工具。导入 sql
包
import "sql"
SQL 数据源名称
sql
包使用 Go 驱动程序连接到 SQL 数据库。数据源名称 (DSN)(也称为连接字符串)由使用的驱动程序决定。
# Amazon Athena Driver DSN
s3://myorgqueryresults/?accessID=AKIAJLO3F...®ion=us-west-1&secretAccessKey=NnQ7MUMp9PYZsmD47c%2BSsXGOFsd%2F...
s3://myorgqueryresults/?accessID=AKIAJLO3F...&db=dbname&missingAsDefault=false&missingAsEmptyString=false®ion=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¶mN=valueN
username[:password]@accountname/dbname?param1=value1¶mN=valueN
username[:password]@hostname:port/dbname/schemaname?account=<your_account>¶m1=value1¶mN=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¶m2=value
bigquery://projectid/location?param1=value¶m2=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 参数
使用 BigQuery DSN 中的 credentials URL 参数提供您的 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 VM 中使用托管身份
azure auth=MSI
函数
此页是否对您有帮助?
感谢您的反馈!