写入 PostgreSQL
使用 Flux 将数据写入 PostgreSQL
导入
sql包。将数据管道传输到
sql.to()中,并提供以下参数- driverName: postgres
- dataSourceName: 请参阅 数据源名称
- table: 要写入的表
- batchSize: 每次调用
Exec时可以排队的参数或列的数量(默认为10000)
import "sql"
data
|> sql.to(
driverName: "postgres",
dataSourceName: "postgresql://username:password@localhost:5432",
table: "example_table",
)
PostgreSQL 数据源名称
postgres 驱动程序使用以下 DSN 语法(也称为连接字符串)
postgres://username:password@localhost:5432/dbname?param=value
Flux 到 PostgreSQL 数据类型转换
sql.to() 将 Flux 数据类型转换为 PostgreSQL 数据类型。
| Flux 数据类型 | PostgreSQL 数据类型 |
|---|---|
| float | FLOAT |
| int | BIGINT |
| uint | BIGINT |
| string | TEXT |
| bool | BOOL |
| time | TIMESTAMP |
此页面是否对您有帮助?
感谢您的反馈!