Documentation
¶
Index ¶
- type BaseConnector
- func (c *BaseConnector) Close() error
- func (c *BaseConnector) Execute(sql string) (int64, error)
- func (c *BaseConnector) GetDatabaseName() string
- func (c *BaseConnector) GetDriverName() string
- func (c *BaseConnector) IsConnected() bool
- func (c *BaseConnector) Query(sql string) ([]map[string]interface{}, []string, error)
- type Column
- type Connector
- type MySQLConnector
- func (c *MySQLConnector) Connect() error
- func (c *MySQLConnector) GetColumns(tableName string) ([]Column, error)
- func (c *MySQLConnector) GetDatabases() ([]string, error)
- func (c *MySQLConnector) GetSchema() (*Schema, error)
- func (c *MySQLConnector) GetTables() ([]string, error)
- func (c *MySQLConnector) SwitchDatabase(dbName string) error
- type PostgresConnector
- func (c *PostgresConnector) Connect() error
- func (c *PostgresConnector) GetColumns(tableName string) ([]Column, error)
- func (c *PostgresConnector) GetDatabases() ([]string, error)
- func (c *PostgresConnector) GetSchema() (*Schema, error)
- func (c *PostgresConnector) GetTables() ([]string, error)
- func (c *PostgresConnector) SwitchDatabase(dbName string) error
- type SQLiteConnector
- func (c *SQLiteConnector) Connect() error
- func (c *SQLiteConnector) GetColumns(tableName string) ([]Column, error)
- func (c *SQLiteConnector) GetDatabases() ([]string, error)
- func (c *SQLiteConnector) GetSchema() (*Schema, error)
- func (c *SQLiteConnector) GetTables() ([]string, error)
- func (c *SQLiteConnector) SwitchDatabase(dbName string) error
- type Schema
- type Table
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseConnector ¶
type BaseConnector struct {
// contains filtered or unexported fields
}
BaseConnector implements common database operations
func (*BaseConnector) Close ¶
func (c *BaseConnector) Close() error
Close closes the database connection
func (*BaseConnector) Execute ¶
func (c *BaseConnector) Execute(sql string) (int64, error)
Execute runs an INSERT/UPDATE/DELETE query
func (*BaseConnector) GetDatabaseName ¶
func (c *BaseConnector) GetDatabaseName() string
GetDatabaseName returns the database name
func (*BaseConnector) GetDriverName ¶
func (c *BaseConnector) GetDriverName() string
GetDriverName returns the driver name
func (*BaseConnector) IsConnected ¶
func (c *BaseConnector) IsConnected() bool
IsConnected checks if database is connected
type Connector ¶
type Connector interface {
Connect() error
Close() error
IsConnected() bool
Query(sql string) ([]map[string]interface{}, []string, error)
Execute(sql string) (int64, error)
GetTables() ([]string, error)
GetColumns(tableName string) ([]Column, error)
GetSchema() (*Schema, error)
GetDatabases() ([]string, error)
SwitchDatabase(dbName string) error
GetDriverName() string
GetDatabaseName() string
}
Connector interface for database operations
func NewConnector ¶
func NewConnector(cfg *config.DatabaseConfig) (Connector, error)
NewConnector creates a new database connector based on driver type
type MySQLConnector ¶
type MySQLConnector struct {
BaseConnector
}
MySQLConnector implements Connector for MySQL
func NewMySQLConnector ¶
func NewMySQLConnector(cfg *config.DatabaseConfig) *MySQLConnector
NewMySQLConnector creates a new MySQL connector
func (*MySQLConnector) Connect ¶
func (c *MySQLConnector) Connect() error
Connect establishes connection to MySQL database
func (*MySQLConnector) GetColumns ¶
func (c *MySQLConnector) GetColumns(tableName string) ([]Column, error)
GetColumns returns columns for a specific table
func (*MySQLConnector) GetDatabases ¶
func (c *MySQLConnector) GetDatabases() ([]string, error)
GetDatabases returns list of all databases on the server
func (*MySQLConnector) GetSchema ¶
func (c *MySQLConnector) GetSchema() (*Schema, error)
GetSchema returns the complete database schema
func (*MySQLConnector) GetTables ¶
func (c *MySQLConnector) GetTables() ([]string, error)
GetTables returns list of tables in the database
func (*MySQLConnector) SwitchDatabase ¶
func (c *MySQLConnector) SwitchDatabase(dbName string) error
SwitchDatabase switches to a different database
type PostgresConnector ¶
type PostgresConnector struct {
BaseConnector
}
PostgresConnector implements Connector for PostgreSQL
func NewPostgresConnector ¶
func NewPostgresConnector(cfg *config.DatabaseConfig) *PostgresConnector
NewPostgresConnector creates a new PostgreSQL connector
func (*PostgresConnector) Connect ¶
func (c *PostgresConnector) Connect() error
Connect establishes connection to PostgreSQL database
func (*PostgresConnector) GetColumns ¶
func (c *PostgresConnector) GetColumns(tableName string) ([]Column, error)
GetColumns returns columns for a specific table
func (*PostgresConnector) GetDatabases ¶
func (c *PostgresConnector) GetDatabases() ([]string, error)
GetDatabases returns list of all databases on the server
func (*PostgresConnector) GetSchema ¶
func (c *PostgresConnector) GetSchema() (*Schema, error)
GetSchema returns the complete database schema
func (*PostgresConnector) GetTables ¶
func (c *PostgresConnector) GetTables() ([]string, error)
GetTables returns list of tables in the database
func (*PostgresConnector) SwitchDatabase ¶
func (c *PostgresConnector) SwitchDatabase(dbName string) error
SwitchDatabase switches to a different database
type SQLiteConnector ¶
type SQLiteConnector struct {
BaseConnector
}
SQLiteConnector implements Connector for SQLite
func NewSQLiteConnector ¶
func NewSQLiteConnector(cfg *config.DatabaseConfig) *SQLiteConnector
NewSQLiteConnector creates a new SQLite connector
func (*SQLiteConnector) Connect ¶
func (c *SQLiteConnector) Connect() error
Connect establishes connection to SQLite database
func (*SQLiteConnector) GetColumns ¶
func (c *SQLiteConnector) GetColumns(tableName string) ([]Column, error)
GetColumns returns columns for a specific table
func (*SQLiteConnector) GetDatabases ¶
func (c *SQLiteConnector) GetDatabases() ([]string, error)
GetDatabases returns list of databases (SQLite has only one)
func (*SQLiteConnector) GetSchema ¶
func (c *SQLiteConnector) GetSchema() (*Schema, error)
GetSchema returns the complete database schema
func (*SQLiteConnector) GetTables ¶
func (c *SQLiteConnector) GetTables() ([]string, error)
GetTables returns list of tables in the database
func (*SQLiteConnector) SwitchDatabase ¶
func (c *SQLiteConnector) SwitchDatabase(dbName string) error
SwitchDatabase is not supported for SQLite