MCPcopy Create free account
hub / github.com/cloudquery/cloudquery / TestConnection

Function TestConnection

plugins/destination/duckdb/client/client.go:90–111  ·  view source on GitHub ↗
(ctx context.Context, _ zerolog.Logger, specBytes []byte)

Source from the content-addressed store, hash-verified

88}
89
90func TestConnection(ctx context.Context, _ zerolog.Logger, specBytes []byte) error {
91 var s Spec
92 if err := json.Unmarshal(specBytes, &s); err != nil {
93 return &plugin.TestConnError{
94 Code: "INVALID_SPEC",
95 Message: fmt.Errorf("failed to unmarshal spec: %w", err),
96 }
97 }
98 s.SetDefaults()
99
100 connector, err := duckdb.NewConnector(amendConnectionString(s.ConnectionString), nil)
101 if err != nil {
102 return err
103 }
104 db := sql.OpenDB(connector)
105 if err := db.PingContext(ctx); err != nil {
106 _ = db.Close()
107 return err
108 }
109
110 return db.Close()
111}
112
113func (c *Client) exec(ctx context.Context, query string, args ...any) error {
114 r, err := c.db.ExecContext(ctx, query, args...)

Callers

nothing calls this directly

Calls 4

SetDefaultsMethod · 0.95
amendConnectionStringFunction · 0.85
ErrorfMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected