Documentation
¶
Index ¶
- type Connection
- type ConnectionInfo
- type Manager
- func (m *Manager) Connect(driver, dsn string) (string, error)
- func (m *Manager) Disconnect(id string) error
- func (m *Manager) Exec(id, query string, args ...any) (int64, error)
- func (m *Manager) Get(id string) (*Connection, error)
- func (m *Manager) List() []ConnectionInfo
- func (m *Manager) Query(id, query string, args ...any) ([]map[string]any, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
Connection represents an active database connection.
type ConnectionInfo ¶
type ConnectionInfo struct {
ID string `json:"id"`
Driver string `json:"driver"`
DSN string `json:"dsn"`
}
ConnectionInfo is a read-only summary of a connection (no *sql.DB exposed).
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages multiple database connections.
func NewManager ¶
func NewManager() *Manager
NewManager creates a new Manager with an empty connection map.
func (*Manager) Connect ¶
Connect opens a new database connection with the given driver and DSN. Supported drivers: "postgres", "sqlite3", "mysql". Returns the connection ID on success.
func (*Manager) Disconnect ¶
Disconnect closes and removes the connection with the given ID.
func (*Manager) Exec ¶
Exec executes a non-SELECT statement (INSERT, UPDATE, DELETE, etc.) on the given connection and returns the number of rows affected.
func (*Manager) Get ¶
func (m *Manager) Get(id string) (*Connection, error)
Get returns the connection with the given ID or an error if not found.
func (*Manager) List ¶
func (m *Manager) List() []ConnectionInfo
List returns info about all active connections.