sqlite

package
v0.0.0-...-12d209d Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package sqlite provides a lightweight SQLite database wrapper using the modernc.org/sqlite driver (pure Go, no CGO required).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ColumnInfo

type ColumnInfo struct {
	Ordinal    int
	Name       string
	Type       string
	NotNull    bool
	Default    *string
	PrimaryKey bool
}

ColumnInfo holds information about a database column.

type DB

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

DB wraps a SQLite database connection with helper methods.

func Open

func Open(path string) (*DB, error)

Open opens an existing SQLite database file.

func (*DB) Close

func (db *DB) Close() error

Close closes the database connection.

func (*DB) Exec

func (db *DB) Exec(stmt string, args ...interface{}) (sql.Result, error)

Exec executes a statement (INSERT, UPDATE, DELETE, DDL).

func (*DB) ForeignKeyInfo

func (db *DB) ForeignKeyInfo(tableName string) ([]ForeignKeyInfo, error)

ForeignKeyInfo returns foreign key information for a table.

func (*DB) Path

func (db *DB) Path() string

Path returns the database file path.

func (*DB) Query

func (db *DB) Query(query string, args ...interface{}) ([]map[string]interface{}, error)

Query executes a SELECT query and returns rows as a slice of maps.

func (*DB) QueryScalar

func (db *DB) QueryScalar(query string, args ...interface{}) (interface{}, error)

QueryScalar executes a query and returns a single scalar value.

func (*DB) RowCount

func (db *DB) RowCount(tableName string) (int64, error)

RowCount returns the number of rows in a table.

func (*DB) TableInfo

func (db *DB) TableInfo(tableName string) ([]ColumnInfo, error)

TableInfo returns column information for a table.

func (*DB) TableNames

func (db *DB) TableNames() ([]string, error)

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

type ForeignKeyInfo

type ForeignKeyInfo struct {
	FromTable  string
	FromColumn string
	ToTable    string
	ToColumn   string
	OnUpdate   string
	OnDelete   string
}

ForeignKeyInfo holds information about a foreign key constraint.

Jump to

Keyboard shortcuts

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