sqlh

package
v0.0.0-...-fee427b Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MapSqlFlatRows

func MapSqlFlatRows[T any](sqlFlatRows *SqlFlatRows, yield func(rowIndex int, obj *T, err error) error) error

func SqlFetchRowsToMaps

func SqlFetchRowsToMaps(rows SqlRowsScanner) ([]map[string]any, error)

func SqlFetchSingleRowToMap

func SqlFetchSingleRowToMap(rows SqlRowsScanner) (map[string]any, error)

Types

type DuckDbSnapshotReader

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

func NewDuckDbSnapshotReader

func NewDuckDbSnapshotReader(dirPath string, prefix string, suffix string) *DuckDbSnapshotReader

func (*DuckDbSnapshotReader) Close

func (r *DuckDbSnapshotReader) Close() error

func (*DuckDbSnapshotReader) Query

func (r *DuckDbSnapshotReader) Query(query string, args ...any) (SqlRowsScanner, error)

func (*DuckDbSnapshotReader) QueryRow

func (r *DuckDbSnapshotReader) QueryRow(query string, args ...any) SqlScanner

func (*DuckDbSnapshotReader) Reload

func (r *DuckDbSnapshotReader) Reload(options ReloadOptions) error

Reload scans for the latest snapshot and opens it

func (*DuckDbSnapshotReader) WaitForDbAvailable

func (r *DuckDbSnapshotReader) WaitForDbAvailable(pollInterval time.Duration)

func (*DuckDbSnapshotReader) WatchForNewFiles

func (r *DuckDbSnapshotReader) WatchForNewFiles(options WatchOptions)

type DuckDbTrackedRow

type DuckDbTrackedRow struct {
	*sql.Row
	// contains filtered or unexported fields
}

func (*DuckDbTrackedRow) Scan

func (tr *DuckDbTrackedRow) Scan(dest ...any) error

type DuckDbTrackedRows

type DuckDbTrackedRows struct {
	*sql.Rows
	// contains filtered or unexported fields
}

func (*DuckDbTrackedRows) Close

func (tr *DuckDbTrackedRows) Close() error

type DuckDbWriter

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

func NewDuckDbWriter

func NewDuckDbWriter(filePath string) (*DuckDbWriter, error)

func (*DuckDbWriter) Begin

func (w *DuckDbWriter) Begin() (*sql.Tx, error)

func (*DuckDbWriter) Close

func (w *DuckDbWriter) Close() error

func (*DuckDbWriter) Exec

func (w *DuckDbWriter) Exec(query string, args ...any) (sql.Result, error)

func (*DuckDbWriter) Query

func (w *DuckDbWriter) Query(query string, args ...any) (*sql.Rows, error)

func (*DuckDbWriter) QueryRow

func (w *DuckDbWriter) QueryRow(query string, args ...any) *sql.Row

func (*DuckDbWriter) Snapshot

func (w *DuckDbWriter) Snapshot(dirPath, prefix, suffix string, maxSnapshots int) error

type ReloadOptions

type ReloadOptions struct {
	DeleteOnClose bool
}

type SqlFlatRows

type SqlFlatRows struct {
	Fields []string `json:"fields"`
	Values []any    `json:"values"`
}

func SqlFetchRowsFlatMap

func SqlFetchRowsFlatMap(rows SqlRowsScanner, fields []string) (*SqlFlatRows, error)

func SqlFetchRowsToFlatMapWithRsFields

func SqlFetchRowsToFlatMapWithRsFields(rows SqlRowsScanner) (*SqlFlatRows, error)

func (*SqlFlatRows) HasRows

func (rows *SqlFlatRows) HasRows() bool

func (*SqlFlatRows) IsEmpty

func (rows *SqlFlatRows) IsEmpty() bool

func (*SqlFlatRows) LastRowFieldUint64Value

func (rows *SqlFlatRows) LastRowFieldUint64Value(fieldName string) uint64

func (*SqlFlatRows) LastRowFieldValue

func (rows *SqlFlatRows) LastRowFieldValue(fieldName string) any

func (*SqlFlatRows) RowCount

func (rows *SqlFlatRows) RowCount() int

type SqlRowLoader

type SqlRowLoader interface {
	LoadFromSqlRow(row SqlScanner) error
}

type SqlRowsScanner

type SqlRowsScanner interface {
	Close() error
	Next() bool
	Err() error
	Scan(dest ...any) error
	Columns() ([]string, error)
}

type SqlScanner

type SqlScanner interface {
	Scan(dest ...any) error
}

type SqlTable

type SqlTable[T SqlRowLoader] struct {
	// contains filtered or unexported fields
}

func NewSqlTable

func NewSqlTable[T SqlRowLoader](db *sql.DB, tableName string) *SqlTable[T]

func NewSqliteTable

func NewSqliteTable[T SqlRowLoader](s *SqliteStorage, name string) *SqlTable[T]

func (*SqlTable[T]) FetchAll

func (table *SqlTable[T]) FetchAll(sql string, args ...any) ([]T, error)

func (*SqlTable[T]) FetchIter

func (table *SqlTable[T]) FetchIter(sql string, args ...any) iter.Seq2[*T, error]

func (*SqlTable[T]) FetchRow

func (table *SqlTable[T]) FetchRow(sql string, args ...any) (*T, error)

type SqliteStorage

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

func SqliteStorageOpenReadOnly

func SqliteStorageOpenReadOnly(dbPath string) (*SqliteStorage, error)

func SqliteStorageOpenReadWrite

func SqliteStorageOpenReadWrite(dbPath string) (*SqliteStorage, error)

func SqliteStorageOpenReadWriteWithInMemoryJournal

func SqliteStorageOpenReadWriteWithInMemoryJournal(dbPath string) (*SqliteStorage, error)

func (*SqliteStorage) Begin

func (s *SqliteStorage) Begin() (*sql.Tx, error)

func (*SqliteStorage) Close

func (s *SqliteStorage) Close() error

Close closes the database connection and stops the vacuum timer.

func (*SqliteStorage) Exec

func (s *SqliteStorage) Exec(sql string, args ...any) (sql.Result, error)

func (*SqliteStorage) Prepare

func (s *SqliteStorage) Prepare(query string) (*sql.Stmt, error)

func (*SqliteStorage) Query

func (s *SqliteStorage) Query(sql string, args ...any) (SqlRowsScanner, error)

func (*SqliteStorage) QueryRow

func (s *SqliteStorage) QueryRow(sql string, args ...any) SqlScanner

type WatchOptions

type WatchOptions struct {
	Interval      time.Duration
	DeleteOnClose bool
}

Jump to

Keyboard shortcuts

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