database

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDatabaseNotFound  = errors.New("database file not found")
	ErrUnsupportedDriver = errors.New("unsupported database driver")
)

Functions

This section is empty.

Types

type Database

type Database struct {
	// contains filtered or unexported fields
}

Database wraps the SQL database connection

func Open

func Open(driver, dsn string, poolMaxConns int) (*Database, error)

Open opens a database connection for the specified driver and DSN. For SQLite, the DSN is a file path (parent directories are created). For PostgreSQL, the DSN is a connection string. poolMaxConns is used only for PostgreSQL to set the connection pool size.

func (*Database) Close

func (d *Database) Close() error

Close closes the database connection

func (*Database) DB

func (d *Database) DB() *sql.DB

DB returns the underlying SQL database connection

func (*Database) RunMigrations

func (d *Database) RunMigrations(driver string) error

RunMigrations runs all pending database migrations from the embedded filesystem for the specified driver ("sqlite" or "postgres").

Jump to

Keyboard shortcuts

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