Documentation
¶
Overview ¶
Package db provides database connection management for sql-http-proxy.
Index ¶
- Constants
- func BindParams(db *sqlx.DB, query string, params map[string]any) (string, []any, error)
- func Connect(cfg config.Config, configDir string) (*sqlx.DB, error)
- func QueryMany(ctx context.Context, db *sqlx.DB, query string, args ...any) ([]map[string]any, error)
- func QueryOne(ctx context.Context, db *sqlx.DB, query string, args ...any) (map[string]any, error)
- type ExecResult
Constants ¶
View Source
const ConnectTimeout = 10 * time.Second
ConnectTimeout is the timeout for validating database connection.
Variables ¶
This section is empty.
Functions ¶
func BindParams ¶
BindParams binds named parameters and rebinds for the driver.
func Connect ¶
Connect establishes a database connection based on the configuration. Returns nil if the configuration doesn't require a database connection. Validates the connection with a ping before returning. If database.init is configured, executes the init SQL after connecting. configDir is used to resolve relative paths in sql_files.
Types ¶
type ExecResult ¶
type ExecResult struct {
LastInsertId *int64 // nil if not available (non-MySQL drivers)
RowsAffected int64
}
ExecResult holds the result of an exec operation.
Click to show internal directories.
Click to hide internal directories.