dsn

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package dsn centralises DSN dialect detection, driver opening, and auth-token injection so the runtime engine and the migrate CLI share one implementation and cannot drift apart.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyAuthToken

func ApplyAuthToken(d, token string) string

ApplyAuthToken appends an authToken query parameter to a libSQL DSN when a token is supplied and the DSN does not already carry one. It is a no-op for an empty token or a DSN that already has authToken=.

func DetectDialect

func DetectDialect(d string) string

DetectDialect inspects the DSN and returns "libsql", "sqlite", or "postgres". SQLite is recognised by the "file:"/"sqlite://" prefix, ":memory:", a ".db"/".sqlite"/".sqlite3" suffix, or — conservatively — a schemeless DSN that looks like a filesystem path rather than a Postgres host/host:port/keyword DSN. "postgres://"/"postgresql://", host:port, user@host and "key=value" DSNs map to "postgres". Use WithDialect/WithDriver to override detection.

  • "libsql": libsql:// wss:// ws:// http:// https:// (Turso / local sqld).
  • "sqlite": file: prefix, sqlite:// prefix, ":memory:", a path ending in ".db"/".sqlite"/".sqlite3", or a schemeless path that is not a Postgres target.
  • "postgres": postgres://, postgresql://, host:port, user@host, or libpq key=value.

func OpenDriver

func OpenDriver(ctx context.Context, d, authToken string) (driver.Driver, error)

OpenDriver opens a driver for the DSN using DetectDialect. For a libsql DSN the auth token (if any) is injected via ApplyAuthToken. The token is ignored for non-libsql dialects.

Types

This section is empty.

Jump to

Keyboard shortcuts

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