MCPcopy Create free account
hub / github.com/dolthub/doltgresql / GetSqlDatabaseFromContext

Function GetSqlDatabaseFromContext

core/context.go:194–207  ·  view source on GitHub ↗

GetSqlDatabaseFromContext returns the database from the context. Uses the context's current database if an empty string is provided. Returns nil if the database was not found.

(ctx *sql.Context, database string)

Source from the content-addressed store, hash-verified

192// GetSqlDatabaseFromContext returns the database from the context. Uses the context's current database if an empty
193// string is provided. Returns nil if the database was not found.
194func GetSqlDatabaseFromContext(ctx *sql.Context, database string) (sql.Database, error) {
195 session := dsess.DSessFromSess(ctx.Session)
196 if len(database) == 0 {
197 database = ctx.GetCurrentDatabase()
198 }
199 db, err := session.Provider().Database(ctx, database)
200 if err != nil {
201 if sql.ErrDatabaseNotFound.Is(err) {
202 return nil, nil
203 }
204 return nil, err
205 }
206 return db, nil
207}
208
209// GetSqlTableFromContext returns the table from the context. Uses the context's current database if an empty database
210// name is provided. Returns nil if no table was found.

Callers 5

RowIterMethod · 0.92
RowIterMethod · 0.92
RowIterMethod · 0.92
RowIterMethod · 0.92
GetSqlTableFromContextFunction · 0.85

Calls 1

DatabaseMethod · 0.45

Tested by

no test coverage detected