Documentation
¶
Index ¶
- func NewConnection(cfg *config.DatabaseConfig, log logger.Logger) (types.Interface, error)
- type Connection
- func (c *Connection) Begin(ctx context.Context) (types.Tx, error)
- func (c *Connection) BeginTx(ctx context.Context, opts *sql.TxOptions) (types.Tx, error)
- func (c *Connection) Close() error
- func (c *Connection) CreateMigrationTable(ctx context.Context) error
- func (c *Connection) DatabaseType() string
- func (c *Connection) Exec(ctx context.Context, query string, args ...any) (sql.Result, error)
- func (c *Connection) GetMigrationTable() string
- func (c *Connection) Health(ctx context.Context) error
- func (c *Connection) Prepare(ctx context.Context, query string) (types.Statement, error)
- func (c *Connection) Query(ctx context.Context, query string, args ...any) (*sql.Rows, error)
- func (c *Connection) QueryRow(ctx context.Context, query string, args ...any) types.Row
- func (c *Connection) Stats() (map[string]any, error)
- type Statement
- type Transaction
- func (t *Transaction) Commit() error
- func (t *Transaction) Exec(ctx context.Context, query string, args ...any) (sql.Result, error)
- func (t *Transaction) Prepare(ctx context.Context, query string) (types.Statement, error)
- func (t *Transaction) Query(ctx context.Context, query string, args ...any) (*sql.Rows, error)
- func (t *Transaction) QueryRow(ctx context.Context, query string, args ...any) types.Row
- func (t *Transaction) Rollback() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewConnection ¶
NewConnection creates and returns an Oracle-backed types.Interface using the provided database configuration and logger. It returns an error if cfg is nil, if the connection cannot be opened, or if an initial ping to the database fails. The function uses cfg.ConnectionString when present or constructs a DSN from host/port and Oracle service/SID/database, configures the connection pool from cfg.Pool, verifies connectivity with a 10-second timeout, and logs connection details.
Types ¶
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection implements the types.Interface for Oracle
func (*Connection) CreateMigrationTable ¶
func (c *Connection) CreateMigrationTable(ctx context.Context) error
CreateMigrationTable creates the migration table if it doesn't exist
func (*Connection) DatabaseType ¶
func (c *Connection) DatabaseType() string
DatabaseType returns the database type
func (*Connection) GetMigrationTable ¶
func (c *Connection) GetMigrationTable() string
GetMigrationTable returns the migration table name for Oracle
func (*Connection) Health ¶
func (c *Connection) Health(ctx context.Context) error
Health checks database connectivity
type Statement ¶ added in v0.2.0
type Statement struct {
// contains filtered or unexported fields
}
Statement wraps sql.Stmt to implement types.Statement
type Transaction ¶ added in v0.2.0
type Transaction struct {
// contains filtered or unexported fields
}
Transaction wraps sql.Tx to implement types.Tx
func (*Transaction) Commit ¶ added in v0.2.0
func (t *Transaction) Commit() error
Commit commits the transaction
func (*Transaction) Exec ¶ added in v0.2.0
Exec executes a query without returning rows within the transaction
func (*Transaction) Prepare ¶ added in v0.2.0
Prepare creates a prepared statement within the transaction
func (*Transaction) QueryRow ¶ added in v0.2.0
QueryRow executes a query that returns a single row within the transaction
func (*Transaction) Rollback ¶ added in v0.2.0
func (t *Transaction) Rollback() error
Rollback rolls back the transaction