database

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2026 License: MIT Imports: 16 Imported by: 0 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

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