db

package
v0.0.0-...-c1e6758 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(ctx context.Context, tp trace.TracerProvider, driver, dsn string) (db *sql.DB, err error)

Connect returns a database handler.

func ConnectMySQL

func ConnectMySQL(tp trace.TracerProvider, dsn string) (db *sql.DB, err error)

ConnectMySQL returns a MySQL database handler which is safe for concurrent access.

func ConnectSQLite

func ConnectSQLite(tp trace.TracerProvider, dsn string) (db *sql.DB, err error)

ConnectSQLite returns a SQLlite database handler which is NOT safe for concurrent access.

func FormatOptionalString

func FormatOptionalString(s string) *string

FormatOptionalString returns the nil value when the string is empty.

func FormatOptionalTime

func FormatOptionalTime(nt sql.NullTime) *string

FormatOptionalTime returns the nil value when the value is NULL in the db.

func FormatTime

func FormatTime(t time.Time) string

FormatTime returns an empty string when t has the zero value.

func MigrateEnduroDatabase

func MigrateEnduroDatabase(db *sql.DB) error

func MigrateEnduroStorageDatabase

func MigrateEnduroStorageDatabase(db *sql.DB) error

Types

type Config

type Config struct {
	// Driver specifies the database driver (e.g. "mysql" or "sqlite3").
	Driver string

	// DSN (Data Source Name) specifies the database connection information.
	DSN string

	// Migrate specifies whether to run migrations (true) to upgrade the
	// database schema or not (false).
	Migrate bool
}

Jump to

Keyboard shortcuts

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