dbtarget

package
v1.7.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 30, 2026 License: Apache-2.0 Imports: 8 Imported by: 2 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
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

type Connection struct {
	DB      *sql.DB
	Dialect string
	Schema  string
}

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 Dialect

type Dialect string
const (
	Postgres  Dialect = "postgres"
	SQLite    Dialect = "sqlite"
	SQLServer Dialect = "sqlserver"
)

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

type ResolveConnection func(ctx context.Context, reference string) (string, error)

ResolveConnection turns a connection:// reference into a DSN. It is injected so this package stays free of the connection store and its dependencies.

type Target

type Target struct {
	Dialect Dialect
	DSN     string
}

func Parse

func Parse(raw string) (Target, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL