diff --git a/internal/impl/sql/conn_fields.go b/internal/impl/sql/conn_fields.go index 10910882c2..04cd101eeb 100644 --- a/internal/impl/sql/conn_fields.go +++ b/internal/impl/sql/conn_fields.go @@ -9,7 +9,7 @@ import ( "github.com/benthosdev/benthos/v4/public/service" ) -var driverField = service.NewStringEnumField("driver", "mysql", "postgres", "clickhouse", "mssql", "sqlite", "oracle"). +var driverField = service.NewStringEnumField("driver", "mysql", "postgres", "clickhouse", "mssql", "sqlite", "oracle", "snowflake"). Description("A database [driver](#drivers) to use.") var dsnField = service.NewStringField("dsn"). @@ -26,9 +26,12 @@ The following is a list of supported drivers, their placeholder style, and their ` + "| `postgres` | `postgres://[user[:password]@][netloc][:port][/dbname][?param1=value1&...]` |" + ` ` + "| `mssql` | `sqlserver://[user[:password]@][netloc][:port][?database=dbname¶m1=value1&...]` |" + ` ` + "| `sqlite` | `file:/path/to/filename.db[?param&=value1&...]` |" + ` -` + "| `oracle` | `[username[:password]@][netloc][:port]/service_name?server=server2&server=server3` |" + ` +` + "| `oracle` | `oracle://[username[:password]@][netloc][:port]/service_name?server=server2&server=server3` |" + ` +` + "| `snowflake` | `username[:password]@account_identifier/dbname/schemaname[?param1=value&...¶mN=valueN]` |" + ` -Please note that the ` + "`postgres`" + ` driver enforces SSL by default, you can override this with the parameter ` + "`sslmode=disable`" + ` if required.`). +Please note that the ` + "`postgres`" + ` driver enforces SSL by default, you can override this with the parameter ` + "`sslmode=disable`" + ` if required. + +The ` + "`snowflake`" + ` driver supports multiple DSN formats. Please consult [the docs](https://pkg.go.dev/github.com/snowflakedb/gosnowflake#hdr-Connection_String) for more details. For [key pair authentication](https://docs.snowflake.com/en/user-guide/key-pair-auth.html#configuring-key-pair-authentication), the DSN has the following format: ` + "`@//?warehouse=&role=&authenticator=snowflake_jwt&privateKey=`" + `, where the value for the ` + "`privateKey`" + ` parameter can be constructed from an unencrypted RSA private key file ` + "`rsa_key.p8`" + ` using ` + "`openssl enc -d -base64 -in rsa_key.p8 | basenc --base64url -w0`" + ` (you can use ` + "`gbasenc`" + ` insted of ` + "`basenc`" + ` on OSX if you install ` + "`coreutils`" + ` via Homebrew). If you have a password-encrypted private key, you can decrypt it using ` + "`openssl pkcs8 -in rsa_key_encrypted.p8 -out rsa_key.p8`. Also, make sure fields such as the username are URL-encoded."). Example("clickhouse://username:password@host1:9000,host2:9000/database?dial_timeout=200ms&max_execution_time=60"). Example("foouser:foopassword@tcp(localhost:3306)/foodb"). Example("postgres://foouser:foopass@localhost:5432/foodb?sslmode=disable"). @@ -67,6 +70,7 @@ func rawQueryField() *service.ConfigField { ` + "| `mssql` | Question mark |" + ` ` + "| `sqlite` | Question mark |" + ` ` + "| `oracle` | Colon |" + ` +` + "| `snowflake` | Question mark |" + ` `) } diff --git a/public/components/sql/package.go b/public/components/sql/package.go index e1445cedc1..a23cda3499 100644 --- a/public/components/sql/package.go +++ b/public/components/sql/package.go @@ -14,4 +14,5 @@ import ( _ "github.com/go-sql-driver/mysql" _ "github.com/lib/pq" _ "github.com/sijms/go-ora/v2" + _ "github.com/snowflakedb/gosnowflake" ) diff --git a/website/docs/components/inputs/sql_select.md b/website/docs/components/inputs/sql_select.md index db22113be9..f1db48b0d4 100644 --- a/website/docs/components/inputs/sql_select.md +++ b/website/docs/components/inputs/sql_select.md @@ -106,7 +106,7 @@ A database [driver](#drivers) to use. Type: `string` -Options: `mysql`, `postgres`, `clickhouse`, `mssql`, `sqlite`, `oracle`. +Options: `mysql`, `postgres`, `clickhouse`, `mssql`, `sqlite`, `oracle`, `snowflake`. ### `dsn` @@ -123,10 +123,13 @@ The following is a list of supported drivers, their placeholder style, and their | `postgres` | `postgres://[user[:password]@][netloc][:port][/dbname][?param1=value1&...]` | | `mssql` | `sqlserver://[user[:password]@][netloc][:port][?database=dbname¶m1=value1&...]` | | `sqlite` | `file:/path/to/filename.db[?param&=value1&...]` | -| `oracle` | `[username[:password]@][netloc][:port]/service_name?server=server2&server=server3` | +| `oracle` | `oracle://[username[:password]@][netloc][:port]/service_name?server=server2&server=server3` | +| `snowflake` | `username[:password]@account_identifier/dbname/schemaname[?param1=value&...¶mN=valueN]` | Please note that the `postgres` driver enforces SSL by default, you can override this with the parameter `sslmode=disable` if required. +The `snowflake` driver supports multiple DSN formats. Please consult [the docs](https://pkg.go.dev/github.com/snowflakedb/gosnowflake#hdr-Connection_String) for more details. For [key pair authentication](https://docs.snowflake.com/en/user-guide/key-pair-auth.html#configuring-key-pair-authentication), the DSN has the following format: `@//?warehouse=&role=&authenticator=snowflake_jwt&privateKey=`, where the value for the `privateKey` parameter can be constructed from an unencrypted RSA private key file `rsa_key.p8` using `openssl enc -d -base64 -in rsa_key.p8 | basenc --base64url -w0` (you can use `gbasenc` insted of `basenc` on OSX if you install `coreutils` via Homebrew). If you have a password-encrypted private key, you can decrypt it using `openssl pkcs8 -in rsa_key_encrypted.p8 -out rsa_key.p8`. Also, make sure fields such as the username are URL-encoded. + Type: `string` diff --git a/website/docs/components/outputs/sql.md b/website/docs/components/outputs/sql.md index 834f4b726f..75f2ac460c 100644 --- a/website/docs/components/outputs/sql.md +++ b/website/docs/components/outputs/sql.md @@ -83,7 +83,7 @@ A database [driver](#drivers) to use. Type: `string` -Options: `mysql`, `postgres`, `clickhouse`, `mssql`, `sqlite`, `oracle`. +Options: `mysql`, `postgres`, `clickhouse`, `mssql`, `sqlite`, `oracle`, `snowflake`. ### `data_source_name` @@ -104,6 +104,7 @@ The query to execute. The style of placeholder to use depends on the driver, som | `mssql` | Question mark | | `sqlite` | Question mark | | `oracle` | Colon | +| `snowflake` | Question mark | Type: `string` diff --git a/website/docs/components/outputs/sql_insert.md b/website/docs/components/outputs/sql_insert.md index 61814ea1f7..1623702701 100644 --- a/website/docs/components/outputs/sql_insert.md +++ b/website/docs/components/outputs/sql_insert.md @@ -113,7 +113,7 @@ A database [driver](#drivers) to use. Type: `string` -Options: `mysql`, `postgres`, `clickhouse`, `mssql`, `sqlite`, `oracle`. +Options: `mysql`, `postgres`, `clickhouse`, `mssql`, `sqlite`, `oracle`, `snowflake`. ### `dsn` @@ -130,10 +130,13 @@ The following is a list of supported drivers, their placeholder style, and their | `postgres` | `postgres://[user[:password]@][netloc][:port][/dbname][?param1=value1&...]` | | `mssql` | `sqlserver://[user[:password]@][netloc][:port][?database=dbname¶m1=value1&...]` | | `sqlite` | `file:/path/to/filename.db[?param&=value1&...]` | -| `oracle` | `[username[:password]@][netloc][:port]/service_name?server=server2&server=server3` | +| `oracle` | `oracle://[username[:password]@][netloc][:port]/service_name?server=server2&server=server3` | +| `snowflake` | `username[:password]@account_identifier/dbname/schemaname[?param1=value&...¶mN=valueN]` | Please note that the `postgres` driver enforces SSL by default, you can override this with the parameter `sslmode=disable` if required. +The `snowflake` driver supports multiple DSN formats. Please consult [the docs](https://pkg.go.dev/github.com/snowflakedb/gosnowflake#hdr-Connection_String) for more details. For [key pair authentication](https://docs.snowflake.com/en/user-guide/key-pair-auth.html#configuring-key-pair-authentication), the DSN has the following format: `@//?warehouse=&role=&authenticator=snowflake_jwt&privateKey=`, where the value for the `privateKey` parameter can be constructed from an unencrypted RSA private key file `rsa_key.p8` using `openssl enc -d -base64 -in rsa_key.p8 | basenc --base64url -w0` (you can use `gbasenc` insted of `basenc` on OSX if you install `coreutils` via Homebrew). If you have a password-encrypted private key, you can decrypt it using `openssl pkcs8 -in rsa_key_encrypted.p8 -out rsa_key.p8`. Also, make sure fields such as the username are URL-encoded. + Type: `string` diff --git a/website/docs/components/outputs/sql_raw.md b/website/docs/components/outputs/sql_raw.md index f1d01626f6..a7d5b5fab4 100644 --- a/website/docs/components/outputs/sql_raw.md +++ b/website/docs/components/outputs/sql_raw.md @@ -109,7 +109,7 @@ A database [driver](#drivers) to use. Type: `string` -Options: `mysql`, `postgres`, `clickhouse`, `mssql`, `sqlite`, `oracle`. +Options: `mysql`, `postgres`, `clickhouse`, `mssql`, `sqlite`, `oracle`, `snowflake`. ### `dsn` @@ -126,10 +126,13 @@ The following is a list of supported drivers, their placeholder style, and their | `postgres` | `postgres://[user[:password]@][netloc][:port][/dbname][?param1=value1&...]` | | `mssql` | `sqlserver://[user[:password]@][netloc][:port][?database=dbname¶m1=value1&...]` | | `sqlite` | `file:/path/to/filename.db[?param&=value1&...]` | -| `oracle` | `[username[:password]@][netloc][:port]/service_name?server=server2&server=server3` | +| `oracle` | `oracle://[username[:password]@][netloc][:port]/service_name?server=server2&server=server3` | +| `snowflake` | `username[:password]@account_identifier/dbname/schemaname[?param1=value&...¶mN=valueN]` | Please note that the `postgres` driver enforces SSL by default, you can override this with the parameter `sslmode=disable` if required. +The `snowflake` driver supports multiple DSN formats. Please consult [the docs](https://pkg.go.dev/github.com/snowflakedb/gosnowflake#hdr-Connection_String) for more details. For [key pair authentication](https://docs.snowflake.com/en/user-guide/key-pair-auth.html#configuring-key-pair-authentication), the DSN has the following format: `@//?warehouse=&role=&authenticator=snowflake_jwt&privateKey=`, where the value for the `privateKey` parameter can be constructed from an unencrypted RSA private key file `rsa_key.p8` using `openssl enc -d -base64 -in rsa_key.p8 | basenc --base64url -w0` (you can use `gbasenc` insted of `basenc` on OSX if you install `coreutils` via Homebrew). If you have a password-encrypted private key, you can decrypt it using `openssl pkcs8 -in rsa_key_encrypted.p8 -out rsa_key.p8`. Also, make sure fields such as the username are URL-encoded. + Type: `string` @@ -157,6 +160,7 @@ The query to execute. The style of placeholder to use depends on the driver, som | `mssql` | Question mark | | `sqlite` | Question mark | | `oracle` | Colon | +| `snowflake` | Question mark | Type: `string` diff --git a/website/docs/components/processors/sql.md b/website/docs/components/processors/sql.md index b2548902f0..b3d0311ccb 100644 --- a/website/docs/components/processors/sql.md +++ b/website/docs/components/processors/sql.md @@ -73,7 +73,7 @@ A database [driver](#drivers) to use. Type: `string` -Options: `mysql`, `postgres`, `clickhouse`, `mssql`, `sqlite`, `oracle`. +Options: `mysql`, `postgres`, `clickhouse`, `mssql`, `sqlite`, `oracle`, `snowflake`. ### `data_source_name` @@ -94,6 +94,7 @@ The query to execute. The style of placeholder to use depends on the driver, som | `mssql` | Question mark | | `sqlite` | Question mark | | `oracle` | Colon | +| `snowflake` | Question mark | Type: `string` diff --git a/website/docs/components/processors/sql_insert.md b/website/docs/components/processors/sql_insert.md index 0d662cec8c..54a990af77 100644 --- a/website/docs/components/processors/sql_insert.md +++ b/website/docs/components/processors/sql_insert.md @@ -101,7 +101,7 @@ A database [driver](#drivers) to use. Type: `string` -Options: `mysql`, `postgres`, `clickhouse`, `mssql`, `sqlite`, `oracle`. +Options: `mysql`, `postgres`, `clickhouse`, `mssql`, `sqlite`, `oracle`, `snowflake`. ### `dsn` @@ -118,10 +118,13 @@ The following is a list of supported drivers, their placeholder style, and their | `postgres` | `postgres://[user[:password]@][netloc][:port][/dbname][?param1=value1&...]` | | `mssql` | `sqlserver://[user[:password]@][netloc][:port][?database=dbname¶m1=value1&...]` | | `sqlite` | `file:/path/to/filename.db[?param&=value1&...]` | -| `oracle` | `[username[:password]@][netloc][:port]/service_name?server=server2&server=server3` | +| `oracle` | `oracle://[username[:password]@][netloc][:port]/service_name?server=server2&server=server3` | +| `snowflake` | `username[:password]@account_identifier/dbname/schemaname[?param1=value&...¶mN=valueN]` | Please note that the `postgres` driver enforces SSL by default, you can override this with the parameter `sslmode=disable` if required. +The `snowflake` driver supports multiple DSN formats. Please consult [the docs](https://pkg.go.dev/github.com/snowflakedb/gosnowflake#hdr-Connection_String) for more details. For [key pair authentication](https://docs.snowflake.com/en/user-guide/key-pair-auth.html#configuring-key-pair-authentication), the DSN has the following format: `@//?warehouse=&role=&authenticator=snowflake_jwt&privateKey=`, where the value for the `privateKey` parameter can be constructed from an unencrypted RSA private key file `rsa_key.p8` using `openssl enc -d -base64 -in rsa_key.p8 | basenc --base64url -w0` (you can use `gbasenc` insted of `basenc` on OSX if you install `coreutils` via Homebrew). If you have a password-encrypted private key, you can decrypt it using `openssl pkcs8 -in rsa_key_encrypted.p8 -out rsa_key.p8`. Also, make sure fields such as the username are URL-encoded. + Type: `string` diff --git a/website/docs/components/processors/sql_raw.md b/website/docs/components/processors/sql_raw.md index 669f418c6f..e9d411996c 100644 --- a/website/docs/components/processors/sql_raw.md +++ b/website/docs/components/processors/sql_raw.md @@ -113,7 +113,7 @@ A database [driver](#drivers) to use. Type: `string` -Options: `mysql`, `postgres`, `clickhouse`, `mssql`, `sqlite`, `oracle`. +Options: `mysql`, `postgres`, `clickhouse`, `mssql`, `sqlite`, `oracle`, `snowflake`. ### `dsn` @@ -130,10 +130,13 @@ The following is a list of supported drivers, their placeholder style, and their | `postgres` | `postgres://[user[:password]@][netloc][:port][/dbname][?param1=value1&...]` | | `mssql` | `sqlserver://[user[:password]@][netloc][:port][?database=dbname¶m1=value1&...]` | | `sqlite` | `file:/path/to/filename.db[?param&=value1&...]` | -| `oracle` | `[username[:password]@][netloc][:port]/service_name?server=server2&server=server3` | +| `oracle` | `oracle://[username[:password]@][netloc][:port]/service_name?server=server2&server=server3` | +| `snowflake` | `username[:password]@account_identifier/dbname/schemaname[?param1=value&...¶mN=valueN]` | Please note that the `postgres` driver enforces SSL by default, you can override this with the parameter `sslmode=disable` if required. +The `snowflake` driver supports multiple DSN formats. Please consult [the docs](https://pkg.go.dev/github.com/snowflakedb/gosnowflake#hdr-Connection_String) for more details. For [key pair authentication](https://docs.snowflake.com/en/user-guide/key-pair-auth.html#configuring-key-pair-authentication), the DSN has the following format: `@//?warehouse=&role=&authenticator=snowflake_jwt&privateKey=`, where the value for the `privateKey` parameter can be constructed from an unencrypted RSA private key file `rsa_key.p8` using `openssl enc -d -base64 -in rsa_key.p8 | basenc --base64url -w0` (you can use `gbasenc` insted of `basenc` on OSX if you install `coreutils` via Homebrew). If you have a password-encrypted private key, you can decrypt it using `openssl pkcs8 -in rsa_key_encrypted.p8 -out rsa_key.p8`. Also, make sure fields such as the username are URL-encoded. + Type: `string` @@ -161,6 +164,7 @@ The query to execute. The style of placeholder to use depends on the driver, som | `mssql` | Question mark | | `sqlite` | Question mark | | `oracle` | Colon | +| `snowflake` | Question mark | Type: `string` diff --git a/website/docs/components/processors/sql_select.md b/website/docs/components/processors/sql_select.md index 69e8d9d48b..9392a3b616 100644 --- a/website/docs/components/processors/sql_select.md +++ b/website/docs/components/processors/sql_select.md @@ -105,7 +105,7 @@ A database [driver](#drivers) to use. Type: `string` -Options: `mysql`, `postgres`, `clickhouse`, `mssql`, `sqlite`, `oracle`. +Options: `mysql`, `postgres`, `clickhouse`, `mssql`, `sqlite`, `oracle`, `snowflake`. ### `dsn` @@ -122,10 +122,13 @@ The following is a list of supported drivers, their placeholder style, and their | `postgres` | `postgres://[user[:password]@][netloc][:port][/dbname][?param1=value1&...]` | | `mssql` | `sqlserver://[user[:password]@][netloc][:port][?database=dbname¶m1=value1&...]` | | `sqlite` | `file:/path/to/filename.db[?param&=value1&...]` | -| `oracle` | `[username[:password]@][netloc][:port]/service_name?server=server2&server=server3` | +| `oracle` | `oracle://[username[:password]@][netloc][:port]/service_name?server=server2&server=server3` | +| `snowflake` | `username[:password]@account_identifier/dbname/schemaname[?param1=value&...¶mN=valueN]` | Please note that the `postgres` driver enforces SSL by default, you can override this with the parameter `sslmode=disable` if required. +The `snowflake` driver supports multiple DSN formats. Please consult [the docs](https://pkg.go.dev/github.com/snowflakedb/gosnowflake#hdr-Connection_String) for more details. For [key pair authentication](https://docs.snowflake.com/en/user-guide/key-pair-auth.html#configuring-key-pair-authentication), the DSN has the following format: `@//?warehouse=&role=&authenticator=snowflake_jwt&privateKey=`, where the value for the `privateKey` parameter can be constructed from an unencrypted RSA private key file `rsa_key.p8` using `openssl enc -d -base64 -in rsa_key.p8 | basenc --base64url -w0` (you can use `gbasenc` insted of `basenc` on OSX if you install `coreutils` via Homebrew). If you have a password-encrypted private key, you can decrypt it using `openssl pkcs8 -in rsa_key_encrypted.p8 -out rsa_key.p8`. Also, make sure fields such as the username are URL-encoded. + Type: `string`