history

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package history stores executed SQL statements in a local SQLite database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultPath

func DefaultPath() string

DefaultPath returns the conventional sqio history database path for the current user, falling back to the temporary directory when the home directory cannot be resolved.

Types

type Entry

type Entry struct {
	ID         int64     `json:"id"`
	SQL        string    `json:"sql"`
	Connection string    `json:"connection"`
	ElapsedMS  int64     `json:"elapsed_ms"`
	ExecutedAt time.Time `json:"executed_at"`
	Tags       string    `json:"tags"`
	Favorite   bool      `json:"favorite"`
	Success    bool      `json:"success"`
	Error      string    `json:"error"`
	RowCount   int       `json:"row_count"`
	Driver     string    `json:"driver"`
}

Entry represents one executed SQL statement persisted in history.

type ListOptions

type ListOptions struct {
	Limit      int
	Search     string
	Connection string
	Favorite   bool
	Tags       string
}

ListOptions filters history entries before returning them in newest-first order.

type Store

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

Store manages the SQLite-backed history database at a specific path.

func New

func New(path string) Store

New returns a Store using path, SQIO_HISTORY_PATH, or the default per-user history location in that order.

func (Store) Append

func (s Store) Append(ctx context.Context, entry Entry) error

Append inserts entry into history, assigning the current UTC time when ExecutedAt is not already set.

func (Store) Get

func (s Store) Get(ctx context.Context, id int64) (Entry, error)

Get returns one history entry by id.

func (Store) List

func (s Store) List(ctx context.Context, limit int) ([]Entry, error)

List returns recent history entries in reverse insertion order. A non-positive limit uses the default maximum of one hundred rows.

func (Store) ListWithOptions

func (s Store) ListWithOptions(ctx context.Context, opts ListOptions) ([]Entry, error)

ListWithOptions returns recent history entries matching opts. A non-positive limit uses the default maximum of one hundred rows.

func (Store) SetFavorite

func (s Store) SetFavorite(ctx context.Context, id int64, favorite bool) error

SetFavorite updates the favorite flag for one history entry.

func (Store) SetTags

func (s Store) SetTags(ctx context.Context, id int64, tags string) error

SetTags updates the free-form tag string for one history entry.

Jump to

Keyboard shortcuts

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