database

package module
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: MIT Imports: 24 Imported by: 1

README

-database-go

Multi-DB support in a neat package

-database-go is part of the kiss-my-package set used by apps like FaceMasq, PaperBag, Celestial, Executrix, and more

Documentation

Index

Constants

View Source
const (
	MySQL   = "mysql"
	PgSQL   = "postgres"
	SQLite  = "sqlite"
	MSSQL   = "mssql"
	MariaDB = "mariadb"
)
View Source
const DBTargetVer = 1

Variables

View Source
var (
	Conn    *bun.DB
	Verbose bool
)
View Source
var (
	ErrMSSql         = fmt.Errorf("`mssql` is not supported yet")
	ErrUnknownEngine = fmt.Errorf("specified engine is not supported yet")
	ErrConnStrFormat = fmt.Errorf("connection string is in the wrong format")
)

Functions

func Schema

func Schema() (*jsonschema.Schema, error)

Types

type DBConn

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

func New

func New(ctx context.Context, connStr string) (*DBConn, error)

func (*DBConn) Close

func (db *DBConn) Close(ctx context.Context) (context.Context, error)

func (*DBConn) Conn

func (db *DBConn) Conn() *bun.DB

func (*DBConn) ConnStr

func (db *DBConn) ConnStr() string

func (*DBConn) DB

func (db *DBConn) DB() *bun.DB

func (*DBConn) Engine

func (db *DBConn) Engine() string

func (*DBConn) Prepare

func (db *DBConn) Prepare(ctx context.Context, lookForTable string, doPreparation func(ctx context.Context, dbConn *DBConn) error) error

type TestContainer

type TestContainer interface {
	Close() error
	GetConnection() containers.ConnectionParams
}
var (
	RunningContainer TestContainer
	DBEngines        []string
)

func ConnectToTest

func ConnectToTest(t *testing.T, ctx context.Context, engine string) (context.Context, TestContainer, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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