db

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: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Column

type Column struct {
	Name       string `json:"name"`
	Type       string `json:"type"`
	Nullable   bool   `json:"nullable"`
	PrimaryKey bool   `json:"primary_key"`
	ForeignKey string `json:"foreign_key,omitempty"`
}

Column represents a table column

type ConnectionConfig

type ConnectionConfig struct {
	ID       string
	DBType   string // postgres, mysql
	Host     string
	Port     int
	Database string
	Username string
	Password string
}

ConnectionConfig holds database connection parameters

type ConnectorManager

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

ConnectorManager manages multiple database connections

func NewConnectorManager

func NewConnectorManager() *ConnectorManager

NewConnectorManager creates a new connector manager

func (*ConnectorManager) Connect

func (cm *ConnectorManager) Connect(cfg ConnectionConfig) error

Connect establishes a new database connection

func (*ConnectorManager) ConnectDefault

func (cm *ConnectorManager) ConnectDefault(cfg ConnectionConfig) error

ConnectDefault connects to database using default connection ID

func (*ConnectorManager) Disconnect

func (cm *ConnectorManager) Disconnect(id string) error

Disconnect closes and removes a connection

func (*ConnectorManager) DisconnectAll

func (cm *ConnectorManager) DisconnectAll() error

DisconnectAll closes all connections

func (*ConnectorManager) GetConnection

func (cm *ConnectorManager) GetConnection(id string) (*sqlx.DB, error)

GetConnection retrieves a connection by ID

func (*ConnectorManager) GetDefaultConnection

func (cm *ConnectorManager) GetDefaultConnection() (*sqlx.DB, error)

GetDefaultConnection retrieves the default connection

func (*ConnectorManager) ListConnections

func (cm *ConnectorManager) ListConnections() []string

ListConnections returns all active connection IDs

func (*ConnectorManager) TestConnection

func (cm *ConnectorManager) TestConnection(cfg ConnectionConfig) error

TestConnection tests if a connection can be established

type Crypto

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

Crypto handles encryption/decryption of sensitive data

func NewCrypto

func NewCrypto(key string) (*Crypto, error)

NewCrypto creates a new crypto instance

func (*Crypto) Decrypt

func (c *Crypto) Decrypt(ciphertext string) (string, error)

Decrypt decrypts ciphertext using AES-GCM

func (*Crypto) Encrypt

func (c *Crypto) Encrypt(plaintext string) (string, error)

Encrypt encrypts plaintext using AES-GCM

type QueryExecutor

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

QueryExecutor executes read-only SQL queries

func NewQueryExecutor

func NewQueryExecutor(db *sqlx.DB, maxRows int, timeoutSeconds int) *QueryExecutor

NewQueryExecutor creates a new query executor

func (*QueryExecutor) Execute

func (qe *QueryExecutor) Execute(sql string) (*QueryResult, error)

Execute executes a SQL query with safety checks

func (*QueryExecutor) Explain

func (qe *QueryExecutor) Explain(sql string) (string, error)

Explain returns the query execution plan

type QueryResult

type QueryResult struct {
	Columns         []string                 `json:"columns"`
	Rows            []map[string]interface{} `json:"rows"`
	RowCount        int                      `json:"row_count"`
	ExecutionTimeMs int64                    `json:"execution_time_ms"`
}

QueryResult represents the result of a query execution

type SchemaExtractor

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

SchemaExtractor extracts database schema information

func NewSchemaExtractor

func NewSchemaExtractor(db *sqlx.DB, dbType string) *SchemaExtractor

NewSchemaExtractor creates a new schema extractor

func (*SchemaExtractor) FormatSchemaForLLM

func (se *SchemaExtractor) FormatSchemaForLLM() (string, error)

FormatSchemaForLLM formats schema as text for LLM prompt

func (*SchemaExtractor) GetFullSchema

func (se *SchemaExtractor) GetFullSchema() ([]Table, error)

GetFullSchema retrieves schema for all tables

func (*SchemaExtractor) GetTableSchema

func (se *SchemaExtractor) GetTableSchema(tableName string) (*Table, error)

GetTableSchema retrieves detailed schema for a specific table

func (*SchemaExtractor) GetTables

func (se *SchemaExtractor) GetTables() ([]string, error)

GetTables retrieves all tables in the database

type Table

type Table struct {
	Name    string   `json:"name"`
	Columns []Column `json:"columns"`
}

Table represents a database table

Jump to

Keyboard shortcuts

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