sqlitebe

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DQL
	SELECT  = "select"
	PRAGMA  = "pragma"
	WITH    = "with"
	EXPLAIN = "explain"
	VALUES  = "values"

	// max rows fetched when browsing a table from the tree view
	FetchLimit = 200
)

Variables

This section is empty.

Functions

func GetDbFile

func GetDbFile() string

Types

type Backend

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

Backend adapts the sqlite data-access layer to the db.Backend contract.

func Connect

func Connect(cfg Config) (*Backend, error)

Connect opens the sqlite file and pings it before returning. The file must already exist.

func (*Backend) Close

func (b *Backend) Close() error

func (*Backend) ColumnIndexTypes

func (b *Backend) ColumnIndexTypes(_ string, table string) (map[string]string, error)

ColumnIndexTypes returns index type labels for indexed columns; namespace is ignored.

func (*Backend) ColumnsMeta

func (b *Backend) ColumnsMeta(_ string, table string) ([]db.ColumnMeta, error)

ColumnsMeta returns column metadata for a table; the namespace argument is ignored.

func (*Backend) FetchTable

func (b *Backend) FetchTable(_ string, table string, limit int) (*data.Frame, error)

FetchTable loads up to limit rows of a table; the namespace argument is ignored.

func (*Backend) Kind

func (b *Backend) Kind() string

func (*Backend) Namespaces

func (b *Backend) Namespaces() ([]string, error)

Namespaces returns a single empty namespace: sqlite files have no database/schema level.

func (*Backend) PrimaryKeys

func (b *Backend) PrimaryKeys(_ string, table string) ([]string, error)

PrimaryKeys lists the primary-key column names of a table; the namespace argument is ignored.

func (*Backend) Run

func (b *Backend) Run(stmt string) (db.Result, error)

Run executes a statement, routing queries vs. mutations the same way the underlying data-access layer does. Query results come back as an all-string frame.

func (*Backend) Tables

func (b *Backend) Tables(string) ([]string, error)

Tables lists all user tables; the namespace argument is ignored.

func (*Backend) Title

func (b *Backend) Title() string

type Config

type Config struct {
	FilePath string
}

Config holds the connection parameters for a sqlite database file.

type DB

type DB struct {
	*sql.DB
	File string
}
var (
	DbClinet *DB
)

func GetDB

func GetDB() *DB

func NewDB

func NewDB(file string) (*DB, error)

func (*DB) Close

func (db *DB) Close() error

func (*DB) ColumnIndexTypes

func (db *DB) ColumnIndexTypes(table string) (map[string]string, error)

ColumnIndexTypes returns a column→index-type map for table. Priority: PK > UNIQUE > INDEX. SQLite uses PRAGMA table_info for PKs and PRAGMA index_list + index_info for other indexes.

func (*DB) ColumnsMeta

func (db *DB) ColumnsMeta(table string) ([]dbapi.ColumnMeta, error)

ColumnsMeta returns column metadata for table, in ordinal order. The namespace argument is ignored: sqlite files have no schema level. Column comments are not supported and stay empty.

func (*DB) FetchTableFields

func (db *DB) FetchTableFields(table string) ([]string, error)

FetchTableFields returns the column names of a table via PRAGMA table_info.

func (*DB) FetchTableRecords

func (db *DB) FetchTableRecords(table string) ([][]string, error)

func (*DB) ListPrimaryKeys

func (db *DB) ListPrimaryKeys(table string) ([]string, error)

ListPrimaryKeys lists the primary-key column names of table, in pk-ordinal order. Empty when the table has no primary key. The namespace argument is ignored: sqlite files have no schema level.

func (*DB) ListTables

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

ListTables lists all user tables of the sqlite database file.

func (*DB) RawExec

func (db *DB) RawExec(query string) (sql.Result, error)

func (*DB) RawQuery

func (db *DB) RawQuery(query string) (fields []string, records [][]string, err error)

func (*DB) RawSqlCommand

func (db *DB) RawSqlCommand(query string) (rawCmdResult RawCommandResult, err error)

type RawCommandResult

type RawCommandResult struct {
	Fields  []string
	Records [][]string
	Result  sql.Result
	IsDQL   bool
}

Jump to

Keyboard shortcuts

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