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

Method QueryConn

backend/plugin/db/sqlite/sqlite.go:152–176  ·  view source on GitHub ↗

QueryConn queries a SQL statement in a given connection.

(ctx context.Context, conn *sql.Conn, statement string, queryContext db.QueryContext)

Source from the content-addressed store, hash-verified

150
151// QueryConn queries a SQL statement in a given connection.
152func (*Driver) QueryConn(ctx context.Context, conn *sql.Conn, statement string, queryContext db.QueryContext) ([]*v1pb.QueryResult, error) {
153 startTime := time.Now()
154 rows, err := conn.QueryContext(ctx, statement)
155 if err != nil {
156 return nil, err
157 }
158 defer rows.Close()
159
160 result, err := util.RowsToQueryResult(rows, util.MakeCommonValueByTypeName, util.ConvertCommonValue, queryContext.MaximumSQLResultSize)
161 if err != nil {
162 // nolint
163 return []*v1pb.QueryResult{
164 {
165 Error: err.Error(),
166 },
167 }, nil
168 }
169 if err := rows.Err(); err != nil {
170 return nil, err
171 }
172 result.Latency = durationpb.New(time.Since(startTime))
173 result.Statement = statement
174 result.RowsCount = int64(len(result.Rows))
175 return []*v1pb.QueryResult{result}, nil
176}

Callers

nothing calls this directly

Implementers 15

MockDriverbackend/plugin/advisor/utils_for_tests
Driverbackend/plugin/db/bigquery/bigquery.go
Driverbackend/plugin/db/mongodb/mongodb.go
Driverbackend/plugin/db/trino/trino.go
Driverbackend/plugin/db/redshift/redshift.go
Driverbackend/plugin/db/oracle/oracle.go
Driverbackend/plugin/db/dynamodb/dynamodb.go
Driverbackend/plugin/db/cosmosdb/cosmosdb.go
Driverbackend/plugin/db/spanner/spanner.go
Driverbackend/plugin/db/mssql/mssql.go
Driverbackend/plugin/db/mysql/mysql.go
Driverbackend/plugin/db/pg/pg.go

Calls 4

RowsToQueryResultFunction · 0.92
QueryContextMethod · 0.80
CloseMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected