Documentation
¶
Overview ¶
Package history stores executed SQL statements in a local SQLite database.
Index ¶
- func DefaultPath() string
- type Entry
- type ListOptions
- type Store
- func (s Store) Append(ctx context.Context, entry Entry) error
- func (s Store) Get(ctx context.Context, id int64) (Entry, error)
- func (s Store) List(ctx context.Context, limit int) ([]Entry, error)
- func (s Store) ListWithOptions(ctx context.Context, opts ListOptions) ([]Entry, error)
- func (s Store) SetFavorite(ctx context.Context, id int64, favorite bool) error
- func (s Store) SetTags(ctx context.Context, id int64, tags string) error
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 ¶
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 ¶
New returns a Store using path, SQIO_HISTORY_PATH, or the default per-user history location in that order.
func (Store) Append ¶
Append inserts entry into history, assigning the current UTC time when ExecutedAt is not already set.
func (Store) List ¶
List returns recent history entries in reverse insertion order. A non-positive limit uses the default maximum of one hundred rows.
func (Store) ListWithOptions ¶
ListWithOptions returns recent history entries matching opts. A non-positive limit uses the default maximum of one hundred rows.
func (Store) SetFavorite ¶
SetFavorite updates the favorite flag for one history entry.