写入 SQL Server
要使用 Flux 将数据写入 Microsoft SQL Server
导入
sql
程序包。将数据管道输送到
sql.to()
中,并提供以下参数- driverName: sqlserver
- dataSourceName: 请参阅 数据源名称
- table: 要写入的表
- batchSize: 每次调用
Exec
时可以排队的参数或列的数量(默认为10000
)
import "sql"
data
|> sql.to(
driverName: "sqlserver",
dataSourceName: "sqlserver://user:password@localhost:1433?database=examplebdb",
table: "Example.Table",
)
SQL Server 数据源名称
sqlserver
驱动程序使用以下 DSN 语法(也称为连接字符串)
sqlserver://username:password@localhost:1433?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=0143356789
SQL Server ADO 身份验证
使用以下方法之一提供 SQL Server 身份验证凭据作为 ActiveX Data Objects (ADO) DSN 参数
从环境变量检索身份验证凭据
azure auth=ENV
从文件检索身份验证凭据
InfluxDB Cloud 和 InfluxDB OSS 无法 访问底层文件系统,并且不支持从文件读取凭据。要从文件检索 SQL Server 凭据,请在本地计算机上的 Flux REPL 中执行查询。
azure auth=C:\secure\azure.auth
在 DSN 中指定身份验证凭据
# 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 中使用托管标识
有关托管标识的信息,请参阅 Microsoft 托管标识。
azure auth=MSI
Flux 到 SQL Server 数据类型转换
sql.to()
将 Flux 数据类型转换为 SQL Server 数据类型。
Flux 数据类型 | SQL Server 数据类型 |
---|---|
float | FLOAT |
int | BIGINT |
uint | BIGINT |
string | VARCHAR(MAX |
bool | BIT |
time | DATETIMEOFFSET |
此页面是否对您有帮助?
感谢您的反馈!