Open opens a Snowflake driver.
(_ context.Context, dbType storepb.Engine, config db.ConnectionConfig)
| 49 | |
| 50 | // Open opens a Snowflake driver. |
| 51 | func (d *Driver) Open(_ context.Context, dbType storepb.Engine, config db.ConnectionConfig) (db.Driver, error) { |
| 52 | dsn, loggedDSN, err := buildSnowflakeDSN(config) |
| 53 | if err != nil { |
| 54 | return nil, err |
| 55 | } |
| 56 | |
| 57 | slog.Debug("Opening Snowflake driver", |
| 58 | slog.String("dsn", loggedDSN), |
| 59 | slog.String("environment", config.ConnectionContext.EnvironmentID), |
| 60 | slog.String("database", config.ConnectionContext.InstanceID), |
| 61 | ) |
| 62 | db, err := sql.Open("snowflake", dsn) |
| 63 | if err != nil { |
| 64 | panic(err) |
| 65 | } |
| 66 | d.dbType = dbType |
| 67 | d.db = db |
| 68 | d.connectionCtx = config.ConnectionContext |
| 69 | d.databaseName = config.ConnectionContext.DatabaseName |
| 70 | return d, nil |
| 71 | } |
| 72 | |
| 73 | // buildSnowflakeDSN returns the Snowflake Golang DSN and a redacted version of the DSN. |
| 74 | func buildSnowflakeDSN(config db.ConnectionConfig) (string, string, error) { |
nothing calls this directly
no test coverage detected