database

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const SQLiteInitFile = "db/sqlite_init.sql"

SQLiteInitFile is the path to the SQLite schema initialization SQL file.

Variables

This section is empty.

Functions

func Open

func Open(dialect Dialect, dsn string) (*sql.DB, error)

Open opens a database connection for the given dialect and DSN.

func RunMigrations

func RunMigrations(dialect Dialect, dsn string, db *sql.DB) error

RunMigrations applies database migrations based on the dialect.

Types

type Dialect

type Dialect string

Dialect represents the database engine type.

const (
	DialectPostgres Dialect = "postgres"
	DialectSQLite   Dialect = "sqlite"
)

func DetectDialect

func DetectDialect() (Dialect, string)

DetectDialect determines the database dialect and DSN from environment variables. If DATABASE_URL is set, PostgreSQL is used. Otherwise, SQLite is used as the default.

Jump to

Keyboard shortcuts

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