sqlite

package
v0.0.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	TypeExplain            = "EXPLAIN"
	TypeSelect             = "SELECT"
	TypeInsert             = "INSERT"
	TypeUpdate             = "UPDATE"
	TypeDelete             = "DELETE"
	TypeCreateTable        = "CREATE TABLE"
	TypeCreateIndex        = "CREATE INDEX"
	TypeCreateView         = "CREATE VIEW"
	TypeCreateTrigger      = "CREATE TRIGGER"
	TypeCreateVirtualTable = "CREATE VIRTUAL TABLE"
	TypeAlterTable         = "ALTER TABLE"
	TypeVacuum             = "VACUUM"
	TypeDrop               = "DROP"
	TypeAnalyze            = "ANALYZE"
	TypeBegin              = "BEGIN"
	TypeCommit             = "COMMIT"
	TypeRollback           = "ROLLBACK"
	TypeSavepoint          = "SAVEPOINT"
	TypeRelease            = "RELEASE"
	TypeOther              = "OTHER"
)

Variables

View Source
var (
	Driver = "sqlite3-dq"
)
View Source
var (
	ErrInvalidSQL = fmt.Errorf("invalid SQL")
)

Functions

func RegisterDriver

func RegisterDriver(extensions []string, nodeName string, pub CDCPublisher)

func Serialize

func Serialize(ctx context.Context, schema string) ([]byte, error)

func SetGlobalDB

func SetGlobalDB(database *sql.DB)

Types

type CDCPublisher

type CDCPublisher interface {
	Publish(cs *ChangeSet) error
}

type Change

type Change struct {
	Database  string   `json:"database"`
	Table     string   `json:"table"`
	Columns   []string `json:"columns"`
	Operation string   `json:"operation"` // "INSERT", "UPDATE", "DELETE"
	OldRowID  int64    `json:"old_rowid,omitempty"`
	NewRowID  int64    `json:"new_rowid,omitempty"`
	OldValues []any    `json:"old_values,omitempty"`
	NewValues []any    `json:"new_values,omitempty"`
}

type ChangeSet

type ChangeSet struct {
	Node      string   `json:"node"`
	Changes   []Change `json:"changes"`
	Timestamp int64    `json:"timestamp_ns"`
}

func NewChangeSet

func NewChangeSet(node string) *ChangeSet

func (*ChangeSet) AddChange

func (cs *ChangeSet) AddChange(change Change)

func (*ChangeSet) Apply

func (cs *ChangeSet) Apply() error

func (*ChangeSet) Clear

func (cs *ChangeSet) Clear()

func (*ChangeSet) Send

func (cs *ChangeSet) Send(pub CDCPublisher) error

type Request

type Request struct {
	Sql    string         `json:"sql"`
	Params map[string]any `json:"params"`
}

type Response

type Response struct {
	Columns      []string `json:"columns"`
	Rows         [][]any  `json:"rows"`
	RowsAffected int64    `json:"-"`
	NoReturning  bool     `json:"-"`
}

func Exec

func Exec(ctx context.Context, eq execerQuerier, stmt *Statement, params map[string]any) (*Response, error)

func Transaction

func Transaction(ctx context.Context, req []Request) ([]*Response, error)

type Statement

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

func NewStatement

func NewStatement(ctx context.Context, sql string) (*Statement, error)

func NewUnverifiedStatement

func NewUnverifiedStatement(sql string) *Statement

func (*Statement) Begin

func (s *Statement) Begin() bool

func (*Statement) Columns

func (s *Statement) Columns() []string

func (*Statement) Commit

func (s *Statement) Commit() bool

func (*Statement) DDL

func (s *Statement) DDL() bool

func (*Statement) HasDistinct

func (s *Statement) HasDistinct() bool

func (*Statement) HasReturning

func (s *Statement) HasReturning() bool

func (*Statement) IsCreateTable

func (s *Statement) IsCreateTable() bool

func (*Statement) IsDelete

func (s *Statement) IsDelete() bool

func (*Statement) IsExplain

func (s *Statement) IsExplain() bool

func (*Statement) IsInsert

func (s *Statement) IsInsert() bool

func (*Statement) IsSelect

func (s *Statement) IsSelect() bool

func (*Statement) IsUpdate

func (s *Statement) IsUpdate() bool

func (*Statement) Parameters

func (s *Statement) Parameters() []string

func (*Statement) Rollback

func (s *Statement) Rollback() bool

func (*Statement) Source

func (s *Statement) Source() string

func (*Statement) Type

func (s *Statement) Type() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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