libcmdbm 0.2.0
MyBatis-like SQL mapping library for C99
Loading...
Searching...
No Matches
Datasources and their connection pool.

Data Structures

struct  CMDBM_PoolConfig
 How a datasource pools its connections. More...
 
struct  CMDBM_Database
 A datasource: one database, its pool and its statements. More...
 

Functions

CMDBM_DatabaseCMDBM_DatabaseCreate (const char *sourceid, const char *dbmskey, const char *dbcharset, CMDBM_PoolConfig *poolconf, CMUTIL_JsonObject *params)
 Build a datasource in code.
 

Detailed Description

A datasource is one database: the module which talks to it, the pool of connections to it, and the mapper files whose statements may be run against it. Applications which keep their configuration in the JSON file never build one by hand - CMDBM_ContextCreate does it - but the objects are public so that a datasource can be assembled in code.

Function Documentation

◆ CMDBM_DatabaseCreate()

CMDBM_Database * CMDBM_DatabaseCreate ( const char *  sourceid,
const char *  dbmskey,
const char *  dbcharset,
CMDBM_PoolConfig poolconf,
CMUTIL_JsonObject *  params 
)

Build a datasource in code.

Nothing is opened here. The module is initialized, the pool filled and the mappers loaded when the datasource is handed to CMDBM_Context::AddDatabase, so mappers and the monitor interval are set between the two calls.

Both poolconf and params are copied, and the caller keeps ownership of what it passed in.

Parameters
sourceidThe id sessions will name this datasource by.
dbmskeyThe registered name of the DBMS module - "PGSQL", "MARIA", "SQLITE", "ORACLE", "ODBC" or one of an application's own. Matched case insensitively.
dbcharsetThe character set the database stores text in.
poolconfHow the connections are pooled.
paramsThe connection parameters, handed to CMDBM_ModuleInterface::OpenConnection as they are - which keys are expected is up to the module.
Returns
The datasource, or NULL when no module is registered under dbmskey.