Documentation
¶
Index ¶
Constants ¶
const ConnectionPrefix = "connection://"
ConnectionPrefix marks a DSN as a named connection reference, connection://[<namespace>/]<name>.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶ added in v1.1.0
Connection is an open, pinged database with its resolved dialect and schema.
func Open ¶ added in v1.1.0
func Open(ctx context.Context, opts OpenOptions) (Connection, error)
Open resolves a named connection, normalizes the driver and DSN, and pings the database. SQLite opens read-only or read-write as requested.
type OpenOptions ¶ added in v1.1.0
type OpenOptions struct {
// DSN is a connection string or connection://[<namespace>/]<name>.
DSN string
// Driver overrides the dialect parsed from the DSN; it must agree with it.
Driver string
// Schema defaults to main, dbo or public by dialect.
Schema string
// ResolveConnection is required when DSN is a connection:// reference.
ResolveConnection ResolveConnection
ReadOnly bool
}
type ResolveConnection ¶ added in v1.4.0
ResolveConnection turns a connection:// reference into a DSN. It is injected so this package stays free of the connection store and its dependencies.