Skip to main content

GetReadOnlyDB

Uses the dbConfig to create a sqlx DB object for the read replica passed via the config.

def GetReadOnlyDB(
ctx: context.Context,
dbConfig: *DbConfig
) - > *sqlx.DB, error

Uses the dbConfig to create a sqlx DB object for the read replica passed via the config.

Parameters

NameTypeDescription
ctxcontext.ContextThe context for the database operation, used for cancellation and timeouts.
dbConfig*DbConfigThe database configuration containing connection details, including the read replica host. This parameter cannot be nil.

Returns

TypeDescription
*sqlx.DB, errorA sqlx DB object configured for the read replica, or an error if initialization fails.