db

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadSchemasForPool added in v0.3.0

func LoadSchemasForPool(ctx context.Context, pool *ConnectionPool) (map[string]*schema.Schema, error)

Types

type Connection

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

func NewConnection

func NewConnection(cfg config.Database) *Connection

func NewOpenedConnection added in v0.3.0

func NewOpenedConnection(db *sqlx.DB) (*Connection, error)

func (*Connection) Close

func (c *Connection) Close() error

func (*Connection) Connect

func (c *Connection) Connect(ctx context.Context) (*sqlx.DB, error)

func (*Connection) Database added in v0.3.0

func (c *Connection) Database() config.Database

func (*Connection) Transact added in v0.2.0

func (c *Connection) Transact(ctx context.Context, fn func(context.Context) error) error

type ConnectionPool added in v0.3.0

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

func NewConnectionPool added in v0.3.0

func NewConnectionPool() *ConnectionPool

func (*ConnectionPool) Close added in v0.3.0

func (p *ConnectionPool) Close() error

func (*ConnectionPool) Get added in v0.3.0

func (p *ConnectionPool) Get(name string) (*Connection, bool)

func (*ConnectionPool) Setup added in v0.3.0

func (p *ConnectionPool) Setup(ds map[string]config.Database)

type DataLoader

type DataLoader struct{}

func NewDataLoader

func NewDataLoader() *DataLoader

func (*DataLoader) Load

func (l *DataLoader) Load(ctx context.Context, conn *Connection, table string) (TableData, error)

type Inserter added in v0.2.0

type Inserter struct {
}

func NewInserter added in v0.2.0

func NewInserter() *Inserter

func (*Inserter) Insert added in v0.2.0

func (i *Inserter) Insert(
	ctx context.Context,
	conn *Connection,
	table string,
	dataset []map[string]interface{},
) (int64, error)

func (*Inserter) Upsert added in v0.2.0

func (i *Inserter) Upsert(
	ctx context.Context,
	conn *Connection,
	table *schema.Table,
	dataset []map[string]interface{},
) (int64, error)

type PGLoader

type PGLoader struct{}

func NewPGLoader

func NewPGLoader() *PGLoader

func (*PGLoader) Load

func (l *PGLoader) Load(ctx context.Context, conn *Connection) (*schema.Schema, error)

type SchemaLoader

type SchemaLoader interface {
	// Load database schema
	Load(ctx context.Context, conn *Connection) (*schema.Schema, error)
}

type TableData

type TableData []map[string]interface{}

func (*TableData) FilterColumns added in v0.3.0

func (d *TableData) FilterColumns(filter func(col string) bool) TableData

type Transactioner added in v0.2.0

type Transactioner func(context.Context, func(ctx context.Context) error) error

Jump to

Keyboard shortcuts

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