GetDB
Uses the dbConfig to create a sqlx DB object. If the database doesn't exist for the dbConfig, a new one is created using the default database for the provider (e.g., postgres has default dbName as postgres).
def GetDB(
ctx: context.Context,
dbConfig: *DbConfig
) - > (*sqlx.DB, error)
Uses the dbConfig to create a sqlx DB object. If the database doesn't exist for the dbConfig, a new one is created using the default database for the provider (e.g., 'postgres' for PostgreSQL).
Parameters
| Name | Type | Description |
|---|---|---|
| ctx | context.Context | The context for the database operation, allowing for cancellation and timeouts. |
| dbConfig | *DbConfig | The database configuration object containing connection details for PostgreSQL or deprecated host/user/dbName settings. This configuration is used to establish or create the database connection. |
Returns
| Type | Description |
|---|---|
(*sqlx.DB, error) | A pointer to the sqlx.DB object and an error if the database connection could not be established or configured. |