Help us shape the future of Go! Take the 2026 Go Developer Survey

sqlite

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database interface {
	// Record 返回本数据库的记录存储。
	Record() storage.RecordStorage
	// Log 返回同一数据库中的日志存储。
	Log() storage.LogStorage
	// Close 关闭数据库连接,内存库的数据同时释放。
	Close() error
}

Database 是打开的 SQLite 库,提供建在同一个库上的记录存储和日志存储。

func OpenDatabase

func OpenDatabase(opt *DatabaseOpt) (Database, error)

OpenDatabase 打开 SQLite 并创建记录表、索引和日志表。

type DatabaseOpt

type DatabaseOpt struct {
	// Path 是落盘库的文件路径;IsInMemory 为 true 时不使用。
	Path string
	// IsInMemory 库是否只放在内存里?内存库跟着这个 Database 的连接存在,Close 后释放。
	IsInMemory bool
	// BusyTimeout 是等待数据库锁的时间;为 0 时用 5 秒。
	BusyTimeout time.Duration
	// Namespaces 是打开时要创建的 Record 表;运行时访问未声明的 namespace 返回错误。
	Namespaces []storage.RecordNamespace
}

DatabaseOpt 保存数据库位置、锁等待时间和要创建的记录分组。

func NewDatabaseOpt

func NewDatabaseOpt(path string, namespaces ...storage.RecordNamespace) *DatabaseOpt

NewDatabaseOpt 创建落盘 SQLite 配置。

func NewMemoryDatabaseOpt

func NewMemoryDatabaseOpt(namespaces ...storage.RecordNamespace) *DatabaseOpt

NewMemoryDatabaseOpt 创建仅保存在内存中的 SQLite 配置。

Jump to

Keyboard shortcuts

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