CreatePostgresReadOnlyDbConnection
Creates a read-only PostgreSQL database connection using the provided configuration and returns the sqlx.DB object. It pings the database to verify the connection before returning.
def CreatePostgresReadOnlyDbConnection(
ctx: context.Context,
pgConfig: PostgresConfig
) - > *sqlx.DB, error
Creates a read-only PostgreSQL database connection and returns the sqlx.DB object. This function is used to establish a connection for read operations, ensuring that no write operations can be performed through this connection.
Parameters
| Name | Type | Description |
|---|---|---|
| ctx | context.Context | The context for the database operation, used for cancellation and timeouts. |
| pgConfig | PostgresConfig | The configuration details for the PostgreSQL database connection, including credentials and connection parameters. |
Returns
| Type | Description |
|---|---|
*sqlx.DB, error | A pointer to the sqlx.DB object representing the read-only database connection, or an error if the connection cannot be established or pinged. |