database

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ObtainLock

func ObtainLock(dbox DbBox) (bool, error)

func ReleaseLock

func ReleaseLock(dbox DbBox) (bool, error)

Types

type DbBox added in v0.2.1

type DbBox struct {
	Db   *sql.DB
	Type string // TODO: Make this lowercase

	IsPostgres bool // indicates this connection is for PostgreSQL
	IsMysql    bool // indicates this connection is for MySQL
	IsSqlite   bool // indicates this connection is for Sqlite
}

func Connect

func Connect(connection string) (DbBox, error)

func (DbBox) Exec added in v0.2.1

func (dbox DbBox) Exec(qb QueryBox, args ...any) (sql.Result, error)

func (DbBox) ExecMaybeTx added in v0.3.1

func (dbox DbBox) ExecMaybeTx(query string, transaction bool) error

This is a convenience wrapper around running up and down transaction queries

func (DbBox) GetQuery added in v0.2.1

func (dbox DbBox) GetQuery(qb QueryBox) string

func (DbBox) Query added in v0.2.1

func (dbox DbBox) Query(qb QueryBox, args ...any) (*sql.Rows, error)

func (DbBox) QueryRow added in v0.2.1

func (dbox DbBox) QueryRow(qb QueryBox, args ...any) *sql.Row

type QueryBox added in v0.2.0

type QueryBox struct {
	Postgres string
	Mysql    string
	Sqlite   string
}

QueryBox makes it easy to store multiple queries for different databases. Use it when an operation can always be completed with a single query for each database type.

func (QueryBox) For added in v0.2.0

func (qb QueryBox) For(driver string) string

Jump to

Keyboard shortcuts

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