Help us shape the future of Go! Take the 2026 Go Developer Survey

sqlite3x

package module
v0.0.0-...-a5b7898 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: MIT Imports: 5 Imported by: 0

README

go-sqlite3x

a small connection pooling wrapper around ncruces' go-sqlite3

Documentation

Index

Constants

View Source
const ErrClosed = errorstr("database closed")

ErrClosed is returned on use of a closed database.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

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

DB provides a pool of *sqlite3.Conn{}, configured by Driver{}.

func (*DB) Close

func (db *DB) Close() error

Close will close the database.

func (*DB) Exec

func (db *DB) Exec(ctx context.Context, sql string) error

Exec will execute the given SQL on a connection from database pool.

func (*DB) Open

func (db *DB) Open(ctx context.Context) (c *sqlite3.Conn, err error)

Open will attempt to return an idle connection from pool, else opening new. NOTE: you MUST later call db.Release(), or you will hold its slot open indefinitely.

func (*DB) Release

func (db *DB) Release(c *sqlite3.Conn)

Release will release given connection to pool.

func (*DB) With

func (db *DB) With(ctx context.Context, with func(*sqlite3.Conn) error) error

With is functionally equivalent to calling Open() followed by defer db.Release().

type Driver

type Driver struct {

	// OnOpen is an optional hook to
	// be called on connection open.
	OnOpen func(*sqlite3.Conn) error

	// OnClose is an optional hook to
	// be called on connection close.
	OnClose func(*sqlite3.Conn)

	// MaxIdleConns determines
	// how many idle connections
	// are allowed to be open.
	MaxIdleConns int32

	// MaxOpenConns determines
	// how many open connections
	// are allowed at once.
	MaxOpenConns int32
}

Driver determines a set of configuration options used to open a DB{} instance.

func (Driver) Open

func (d Driver) Open(dsn string) (db *DB, err error)

Open will open and briefly test a new DB{} instance to verify it is live.

Jump to

Keyboard shortcuts

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