sqlite

package
v0.0.0-...-489d50b Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2026 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	DataDir string // 数据目录
	Name    string // 数据库文件名(如: charline.db)
}

Config 数据库配置

type DB

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

DB 数据库实例

func New

func New(cfg Config) (*DB, error)

New 创建数据库实例

func (*DB) Close

func (db *DB) Close() error

Close 关闭数据库连接

func (*DB) Conn

func (db *DB) Conn() *sql.DB

Conn 获取底层连接

func (*DB) Exec

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

Exec 执行 SQL 语句(无返回结果)

func (*DB) Migrate

func (db *DB) Migrate() error

Migrate 执行数据库迁移

func (*DB) Path

func (db *DB) Path() string

Path 获取数据库文件路径

func (*DB) Query

func (db *DB) Query(query string, args ...interface{}) (*sql.Rows, error)

Query 执行查询

func (*DB) QueryRow

func (db *DB) QueryRow(query string, args ...interface{}) *sql.Row

QueryRow 执行查询并返回单行

type Migration

type Migration struct {
	Version int    // 迁移版本号
	Name    string // 迁移名称
	SQL     string // SQL 语句
}

Migration 迁移定义

func GetMigrations

func GetMigrations() []Migration

GetMigrations 获取所有迁移

Jump to

Keyboard shortcuts

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