database

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2025 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EncodingISO88591 = "ISO 8859-1"
)

Variables

This section is empty.

Functions

func ConvertISO88591ToUTF8

func ConvertISO88591ToUTF8(data []byte) (string, error)

func GenerateSlice

func GenerateSlice(columnTypes []*sql.ColumnType, mapType service.MapType) []any

func GetType

func GetType(col *sql.ColumnType, mapType service.MapType) any

func Map

func Map(columnsIndex map[string]int, mapType service.MapType, values []any) error

func PlaceHolder

func PlaceHolder(dbType string) string

func QueryBuilder

func QueryBuilder(table string, columns []string, placeHolder string) func(batchCount int) string

func SanitizeString

func SanitizeString(s string) string

func ScanSlice

func ScanSlice(columnsLen int, r *sql.Rows) ([]any, error)

func ScanSliceWithValues

func ScanSliceWithValues(columnsLen int, r *sql.Rows, valueTypes []any) ([]any, error)

Types

type Batch

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

func NewBatch

func NewBatch(size int) *Batch

func (*Batch) AddRow

func (b *Batch) AddRow(row []any)

func (*Batch) IsFull

func (b *Batch) IsFull() bool

func (*Batch) Reset

func (b *Batch) Reset()

func (*Batch) Rows

func (b *Batch) Rows() []any

func (*Batch) Size

func (b *Batch) Size() int

type Database

type Database struct {
	DB map[string]*Info
}

func Connect

func Connect(ctx context.Context, cfg map[string]config.Database) (*Database, error)

func (*Database) Close

func (d *Database) Close()

func (*Database) DatabaseList

func (d *Database) DatabaseList() []string

func (*Database) Exec

func (d *Database) Exec(ctx context.Context, name, query string) (service.Result, error)

func (*Database) IterGet

func (d *Database) IterGet(ctx context.Context, name, query string, mapType service.MapType) ([]string, iter.Seq2[[]any, error], error)

func (*Database) IterSet

func (d *Database) IterSet(ctx context.Context, name, table string, wipe bool, skipError service.SkipError, mapType service.MapType, batchCount int, columns []string, rows iter.Seq2[[]any, error]) (service.Result, error)

func (*Database) Query

func (d *Database) Query(ctx context.Context, name, query string, limit int64) (service.Result, error)

type Info added in v0.1.4

type Info struct {
	DB          *sql.DB
	PlaceHolder string
}

type Result

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

func (*Result) Columns

func (r *Result) Columns() []string

func (*Result) Duration

func (r *Result) Duration() time.Duration

func (*Result) Rows

func (r *Result) Rows() [][]any

func (*Result) RowsAffected

func (r *Result) RowsAffected() int64

Jump to

Keyboard shortcuts

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