MCPcopy Create free account
hub / github.com/bytebase/bytebase / createPgDriver

Function createPgDriver

backend/plugin/schema/pg/testutil_test.go:13–34  ·  view source on GitHub ↗

createPgDriver creates and opens a PostgreSQL driver for the specified database. This is a shared helper function for tests.

(ctx context.Context, host, port, database string)

Source from the content-addressed store, hash-verified

11// createPgDriver creates and opens a PostgreSQL driver for the specified database.
12// This is a shared helper function for tests.
13func createPgDriver(ctx context.Context, host, port, database string) (*pgdb.Driver, error) {
14 driver := &pgdb.Driver{}
15 config := db.ConnectionConfig{
16 DataSource: &storepb.DataSource{
17 Type: storepb.DataSourceType_ADMIN,
18 Username: "postgres",
19 Host: host,
20 Port: port,
21 Database: database,
22 },
23 Password: "root-password",
24 ConnectionContext: db.ConnectionContext{
25 EngineVersion: "16.0",
26 DatabaseName: database,
27 },
28 }
29 _, err := driver.Open(ctx, storepb.Engine_POSTGRES, config)
30 if err != nil {
31 return nil, err
32 }
33 return driver, nil
34}

Calls 1

OpenMethod · 0.95

Tested by

no test coverage detected