store

package
v0.0.0-...-fbd5fee Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuditEntry

type AuditEntry struct {
	ID        string    `db:"id" json:"id"`
	Action    string    `db:"action" json:"action"` // connection_created, query_executed, etc.
	Detail    string    `db:"detail" json:"detail"`
	Level     string    `db:"level" json:"level"` // info, warning, error
	IPAddress string    `db:"ip_address" json:"ip_address"`
	CreatedAt time.Time `db:"created_at" json:"created_at"`
}

AuditEntry represents an audit log entry

type ConnectionProfile

type ConnectionProfile struct {
	ID                string    `db:"id" json:"id"`
	Name              string    `db:"name" json:"name"`
	DBType            string    `db:"db_type" json:"db_type"` // postgres, mysql
	Host              string    `db:"host" json:"host"`
	Port              int       `db:"port" json:"port"`
	Database          string    `db:"database" json:"database"`
	Username          string    `db:"username" json:"username"`
	EncryptedPassword string    `db:"encrypted_password" json:"-"`
	CreatedAt         time.Time `db:"created_at" json:"created_at"`
	UpdatedAt         time.Time `db:"updated_at" json:"updated_at"`
}

ConnectionProfile represents a saved database connection

type QueryRecord

type QueryRecord struct {
	ID              string    `db:"id" json:"id"`
	ConnectionID    string    `db:"connection_id" json:"connection_id"`
	Question        string    `db:"question" json:"question"`
	GeneratedSQL    string    `db:"generated_sql" json:"generated_sql"`
	ExecutionTimeMs int64     `db:"execution_time_ms" json:"execution_time_ms"`
	RowCount        int       `db:"row_count" json:"row_count"`
	Status          string    `db:"status" json:"status"` // success, error
	Error           string    `db:"error" json:"error,omitempty"`
	CreatedAt       time.Time `db:"created_at" json:"created_at"`
}

QueryRecord represents a query execution history entry

type Store

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

func New

func New(dbPath string) (*Store, error)

New creates a new Store instance and initializes the database schema

func (*Store) Close

func (s *Store) Close() error

Close closes the database connection

func (*Store) CreateAuditEntry

func (s *Store) CreateAuditEntry(entry *AuditEntry) error

CreateAuditEntry creates a new audit log entry

func (*Store) CreateConnectionProfile

func (s *Store) CreateConnectionProfile(profile *ConnectionProfile) error

CreateConnectionProfile creates a new connection profile

func (*Store) CreateQueryRecord

func (s *Store) CreateQueryRecord(record *QueryRecord) error

CreateQueryRecord creates a new query record

func (*Store) DB

func (s *Store) DB() *sqlx.DB

DB returns the underlying database connection

func (*Store) DeleteConnectionProfile

func (s *Store) DeleteConnectionProfile(id string) error

DeleteConnectionProfile deletes a connection profile by ID

func (*Store) DeleteQueryRecord

func (s *Store) DeleteQueryRecord(id string) error

DeleteQueryRecord deletes a query record by ID

func (*Store) GetConnectionProfile

func (s *Store) GetConnectionProfile(id string) (*ConnectionProfile, error)

GetConnectionProfile retrieves a connection profile by ID

func (*Store) GetQueryRecord

func (s *Store) GetQueryRecord(id string) (*QueryRecord, error)

GetQueryRecord retrieves a query record by ID

func (*Store) ListAuditEntries

func (s *Store) ListAuditEntries(limit, offset int, level string) ([]AuditEntry, error)

ListAuditEntries retrieves audit entries with pagination and optional level filter

func (*Store) ListConnectionProfiles

func (s *Store) ListConnectionProfiles() ([]ConnectionProfile, error)

ListConnectionProfiles retrieves all connection profiles

func (*Store) ListQueryRecords

func (s *Store) ListQueryRecords(limit, offset int) ([]QueryRecord, error)

ListQueryRecords retrieves query records with pagination

func (*Store) Ping

func (s *Store) Ping() error

Ping checks if the database connection is alive

func (*Store) Transaction

func (s *Store) Transaction(fn func(*sqlx.Tx) error) error

Transaction executes a function within a database transaction

Jump to

Keyboard shortcuts

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