sqlite

package
v0.0.0-...-77b25ca Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteInTx

func DeleteInTx(tx Execer, table string, columns []string, rows [][]interface{}) error

DeleteInTx deletes rows from a table within a transaction.

func InsertInTx

func InsertInTx(tx Execer, table string, columns []string, rows [][]interface{}) error

InsertInTx inserts rows into a table within a transaction.

func QuoteIdent

func QuoteIdent(s string) string

func QuoteIdentList

func QuoteIdentList(columns []string) string

func UpdateInTx

func UpdateInTx(tx Execer, table string, columns []string, rows [][]interface{}) error

UpdateInTx updates rows in a table within a transaction.

Types

type DB

type DB = sqlite.DB

DB is a wrapper around github.com/cnlangzi/sqlite.DB providing read/write separation and migration support.

func NewSinkerDB

func NewSinkerDB(ctx context.Context, dsn string, migrations string) (*DB, error)

NewSinkerDB creates a new SQLite DB with read/write separation and migration support. ModuleName is hardcoded to "dbkrab".

type Execer

type Execer interface {
	Exec(query string, args ...interface{}) (sql.Result, error)
}

Execer is an interface for executing queries

type Sinker

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

Sinker implements sinker.Sinker for SQLite.

func NewSinker

func NewSinker(name string, dsn string, migrations string) (*Sinker, error)

NewSinker creates a new SQLite sinker.

func (*Sinker) Close

func (s *Sinker) Close() error

Close closes the database connection.

func (*Sinker) DatabaseName

func (s *Sinker) DatabaseName() string

DatabaseName returns the database name.

func (*Sinker) DatabaseType

func (s *Sinker) DatabaseType() string

DatabaseType returns the database type.

func (*Sinker) ExecContext

func (s *Sinker) ExecContext(ctx context.Context, query string) error

ExecContext executes a raw SQL query

func (*Sinker) Migrate

func (s *Sinker) Migrate(ctx context.Context) error

Migrate runs the migration for this sinker's database. It re-discovers and re-applies migrations from the configured migrations path.

func (*Sinker) Query

func (s *Sinker) Query(query string, limit int) ([]string, []map[string]any, error)

Query executes a read-only query and returns columns and results. Uses the existing Reader connection instead of creating a temporary one. Returns columns in SQLite table order (not alphabetically sorted). Time columns are automatically formatted to "2006-01-02 15:04:05" via types.Codec.

func (*Sinker) QueryTables

func (s *Sinker) QueryTables() ([]string, error)

QueryTables returns the list of user tables in the sink database. Uses the existing Reader connection instead of creating a temporary one.

func (*Sinker) Truncate

func (s *Sinker) Truncate(ctx context.Context, tables []string) error

Truncate deletes all data from the specified tables. It disables foreign key checks during the operation. Only tables that exist in the database and don't start with sqle_ will be truncated.

func (*Sinker) Write

func (s *Sinker) Write(ctx context.Context, ops []core.Sink) error

Write writes a batch of sink operations to the database.

Jump to

Keyboard shortcuts

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