sql

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2024 License: BSD-3-Clause Imports: 8 Imported by: 8

Documentation

Index

Constants

View Source
const MYSQL_DRIVER string = "mysql"
View Source
const POSTGRES_DRIVER string = "postgres"
View Source
const SQLITE_DRIVER string = "sqlite"

Variables

This section is empty.

Functions

func BeginTransactionError

func BeginTransactionError(t Table, err error) error

BeginTransactionError returns a new error with a default message for database transaction initialization problems wrapping 'err' and prepending with the value of 't's Name() method.

func CommitTransactionError

func CommitTransactionError(t Table, err error) error

CommitTransactionError returns a new error with a default message for problems committing database transactions wrapping 'err' and prepending with the value of 't's Name() method.

func ConfigureDatabase

func ConfigureDatabase(ctx context.Context, db *sql.DB, opts *ConfigureDatabaseOptions) error

func ConfigurePostgresDatabase added in v0.0.8

func ConfigurePostgresDatabase(ctx context.Context, db *sql.DB, opts *ConfigureDatabaseOptions) error

func ConfigureSQLiteDatabase

func ConfigureSQLiteDatabase(ctx context.Context, db *sql.DB, opts *ConfigureDatabaseOptions) error

func ConfigureSQLitePragma

func ConfigureSQLitePragma(ctx context.Context, db *sql.DB, pragma []string) error

func CreateTableIfNecessary

func CreateTableIfNecessary(ctx context.Context, db *sql.DB, t Table) error

func DatabaseConnectionError

func DatabaseConnectionError(t Table, err error) error

DatabaseConnectionError returns a new error with a default message for database connection problems wrapping 'err' and prepending with the value of 't's Name() method.

func DefaultSQLitePragma

func DefaultSQLitePragma() []string

func Driver

func Driver(db *sql.DB) string

func DriverTypeOf

func DriverTypeOf(db *sql.DB) string

func ExecuteStatementError

func ExecuteStatementError(t Table, err error) error

ExecuteStatementError returns a new error with a default message for problems executing database (SQL) statements wrapping 'err' and prepending with the value of 't's Name() method.

func HasPostgresTable added in v0.0.8

func HasPostgresTable(ctx context.Context, db *sql.DB, table_name string) (bool, error)

func HasSQLiteTable

func HasSQLiteTable(ctx context.Context, db *sql.DB, table_name string) (bool, error)

func HasTable

func HasTable(ctx context.Context, db *sql.DB, table_name string) (bool, error)

func InitializeTableError

func InitializeTableError(t Table, err error) error

InitializeTableError returns a new error with a default message for database initialization problems wrapping 'err' and prepending with the value of 't's Name() method.

func LoadDuckDBExtensions added in v0.0.12

func LoadDuckDBExtensions(ctx context.Context, db *db_sql.DB, extensions ...string) error

LoadDuckDBExtensions will issue 'INSTALL' and 'LOAD' statements for 'extensions' using 'db'.

func OpenWithURI

func OpenWithURI(ctx context.Context, db_uri string) (*sql.DB, error)

func PrepareStatementError

func PrepareStatementError(t Table, err error) error

PrepareStatementError returns a new error with a default message for problems preparing database (SQL) statements wrapping 'err' and prepending with the value of 't's Name() method.

func WrapError

func WrapError(t Table, err error) error

WrapError returns a new error wrapping 'err' and prepending with the value of 't's Name() method.

Types

type ConfigureDatabaseOptions

type ConfigureDatabaseOptions struct {
	CreateTablesIfNecessary bool
	Tables                  []Table
	Pragma                  []string
}

func DefaultConfigureDatabaseOptions

func DefaultConfigureDatabaseOptions() *ConfigureDatabaseOptions

type Table

type Table interface {
	Name() string
	Schema(*sql.DB) (string, error)
	InitializeTable(context.Context, *sql.DB) error
	IndexRecord(context.Context, *sql.DB, interface{}) error
}

Jump to

Keyboard shortcuts

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