sqlite

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() connector.Connector

New creates a new SQLiteConnector with default settings.

Types

type SQLiteConnector

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

SQLiteConnector implements connector.Connector for SQLite databases.

func (*SQLiteConnector) AlterTable

func (c *SQLiteConnector) AlterTable(ctx context.Context, tableName string, changes []connector.SchemaChange) error

AlterTable applies a list of schema changes to an existing table. Note: SQLite has limited ALTER TABLE support (no DROP COLUMN before 3.35, no MODIFY COLUMN). We use the supported operations where possible.

func (*SQLiteConnector) BeginTx added in v0.1.5

func (c *SQLiteConnector) BeginTx(ctx context.Context, opts *sql.TxOptions) (*sqlx.Tx, error)

BeginTx starts a new database transaction with the given options.

func (*SQLiteConnector) BuildCount

func (c *SQLiteConnector) BuildCount(_ context.Context, req connector.CountRequest) (string, []interface{}, error)

BuildCount constructs a SELECT COUNT(*) query with optional filtering.

func (*SQLiteConnector) BuildDelete

func (c *SQLiteConnector) BuildDelete(_ context.Context, req connector.DeleteRequest) (string, []interface{}, error)

BuildDelete constructs a DELETE query with parameterized WHERE conditions.

func (*SQLiteConnector) BuildInsert

func (c *SQLiteConnector) BuildInsert(_ context.Context, req connector.InsertRequest) (string, []interface{}, error)

BuildInsert constructs an INSERT query for SQLite. SQLite 3.35+ supports RETURNING, so we include it.

func (*SQLiteConnector) BuildSelect

func (c *SQLiteConnector) BuildSelect(_ context.Context, req connector.SelectRequest) (string, []interface{}, error)

BuildSelect constructs a SELECT query from the given request. SQLite uses double-quote identifier quoting and ? parameter placeholders.

func (*SQLiteConnector) BuildUpdate

func (c *SQLiteConnector) BuildUpdate(_ context.Context, req connector.UpdateRequest) (string, []interface{}, error)

BuildUpdate constructs an UPDATE query with parameterized SET values. Includes RETURNING clause since SQLite 3.35+ supports it.

func (*SQLiteConnector) CallProcedure

func (c *SQLiteConnector) CallProcedure(_ context.Context, name string, _ map[string]interface{}) ([]map[string]interface{}, error)

CallProcedure is not supported for SQLite (no stored procedures).

func (*SQLiteConnector) Connect

Connect opens a connection to the SQLite database file specified in the DSN. The DSN should be a file path (e.g., "/path/to/db.sqlite") or ":memory:" for an in-memory database. Query parameters like ?_journal_mode=WAL are supported.

func (*SQLiteConnector) CreateTable

func (c *SQLiteConnector) CreateTable(ctx context.Context, def model.TableSchema) error

CreateTable creates a new table from a TableSchema definition.

func (*SQLiteConnector) DB

func (c *SQLiteConnector) DB() *sqlx.DB

DB returns the underlying sqlx.DB connection pool.

func (*SQLiteConnector) Disconnect

func (c *SQLiteConnector) Disconnect() error

Disconnect closes the database connection.

func (*SQLiteConnector) DriverName

func (c *SQLiteConnector) DriverName() string

DriverName returns the driver identifier for SQLite.

func (*SQLiteConnector) DropTable

func (c *SQLiteConnector) DropTable(ctx context.Context, tableName string) error

DropTable drops a table from the database.

func (*SQLiteConnector) GetStoredProcedures

func (c *SQLiteConnector) GetStoredProcedures(_ context.Context) ([]model.StoredProcedure, error)

GetStoredProcedures returns an empty list since SQLite does not support stored procedures.

func (*SQLiteConnector) GetTableNames

func (c *SQLiteConnector) GetTableNames(ctx context.Context) ([]string, error)

GetTableNames returns a list of all table names in the database.

func (*SQLiteConnector) IntrospectSchema

func (c *SQLiteConnector) IntrospectSchema(ctx context.Context) (*model.Schema, error)

IntrospectSchema returns the full schema for the SQLite database, including all tables and views.

func (*SQLiteConnector) IntrospectTable

func (c *SQLiteConnector) IntrospectTable(ctx context.Context, tableName string) (*model.TableSchema, error)

IntrospectTable returns the schema for a single table or view.

func (*SQLiteConnector) ParameterPlaceholder

func (c *SQLiteConnector) ParameterPlaceholder(_ int) string

ParameterPlaceholder returns a SQLite-style positional parameter placeholder (?). SQLite ignores the index.

func (*SQLiteConnector) Ping

func (c *SQLiteConnector) Ping(ctx context.Context) error

Ping verifies the database connection is alive.

func (*SQLiteConnector) QuoteIdentifier

func (c *SQLiteConnector) QuoteIdentifier(name string) string

QuoteIdentifier wraps a SQL identifier in double quotes, escaping any embedded double quotes to prevent SQL injection.

func (*SQLiteConnector) SupportsReturning

func (c *SQLiteConnector) SupportsReturning() bool

SupportsReturning indicates that SQLite supports RETURNING clauses (3.35+).

func (*SQLiteConnector) SupportsUpsert

func (c *SQLiteConnector) SupportsUpsert() bool

SupportsUpsert indicates that SQLite supports ON CONFLICT (upsert).

Jump to

Keyboard shortcuts

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