db

package
v0.8.33 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: MIT Imports: 21 Imported by: 2

Documentation

Index

Constants

View Source
const SQLiteDriverName = "sqlite3"

in CGO mode, use the github.com/mattn/go-sqlite3 driver

Variables

View Source
var (
	PostgresDialect = "postgres"
	SqliteDialect   = "sqlite3"
)

Functions

func ApplyPgAppName added in v0.3.35

func ApplyPgAppName(dbUrl string) string

func DefaultDbUrl

func DefaultDbUrl() string

func GetDefaultDbName

func GetDefaultDbName() string

func MigrateUp

func MigrateUp(
	ctx context.Context,

	migrateVia interface{},
	migrationsFS fs.FS,
) error

func MigrateUpEnt

func MigrateUpEnt(
	ctx context.Context,
	clientSchema ent.EntClientSchema,
) error

func Open

func Open(driverName, dialectName, dsn string) (db *sql.DB, err error)

func OpenDefault

func OpenDefault() (db *sql.DB, driverName, dialectName string, err error)

func OpenSqlForEnt

func OpenSqlForEnt() (*entsql.Driver, error)

func ParseDefault

func ParseDefault() (driverName, dialectName, dsn string, err error)

func PostgreSQLDSN

func PostgreSQLDSN(suffix string) string

func SQLiteDSN

func SQLiteDSN(filename string, fileScheme, memory bool) string

func SetDefaultDbName

func SetDefaultDbName(name string)

func TryCreateDB

func TryCreateDB(ctx context.Context, driverName, dialect, dsn, createVia string) error

func Up

func Up(
	ctx context.Context,

	migrateVia interface{},
	migrator *migrate.Migrator,
) error

func WaitForDB

func WaitForDB(ctx context.Context) error

WaitForDB repeatedly tries to connect to the default DB until it either succeeds, or the given context is canceled.

Types

type SQLError

type SQLError interface {
	error
	// commonly implemented pattern
	SQLState() string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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