| GNOME Data Access 4 manual |
|---|
Table of Contents
- Providers' support API
- GdaServerProvider — Base class for all the DBMS providers
- Subclassing GdaDataSelect — Base class for all the data models returned by DBMS providers when a SELECT statement is executed
- GdaPStmt — Prepared statement's base class
- Quark lists — Manages lists of KEY=VALUE pairs
- SQL rendering API — Adapting the SQL to the database's own SQL dialect
- Misc API — Methods dedicated to implementing providers
- Virtual methods for providers
- Virtual methods for recordsets
- Virtual methods for Blob operations
- SQL parser
- Implementation overview
- Tips to write a custom parser
- GdaSqlStatement — Structure which decomposes an SQL statement
- Assembling all the parts
For each database engine, Libgda requires an object which maps Libgda's API to the native API offered by that database engine. That object, a database provider needs to inherit GdaServerProvider and implement its virtual methods.
Database provider objects are generally instantiated once by the Libgda framework and can be used several times to open and work on connections to several databases of the same type.
Since Libgda itself is developed in the C language, and that most
providers are also implemented in that language, the Libgda library
itself contains a set of helper classes and functions to guide you
in the addition of a new provider to the GDA framework. Two reference implementations
are provided in the providers/skel-implementation
directory of Libgda's sources:
in
providers/skel-implementation/capi: a skeleton implementation from scratch for a database accessed through a C API, where all the methods to implement are partially codedin
providers/skel-implementation/models: a skeleton implementation to write a provider for sources which are not databases (which do not implement any SQL) such as the Berkeley DB provider (a BDB database is a key/value collection) or the MDB (MS Access files) provider. This kind of provider "export" tables which are in fact data models.
The helper objects and functions to write database providers are documented in the Providers' support API section.
Libgda's sources contain templates to get started in creating a new database provider. The following templates are available:
the template in the
providers/skel-implementation/capidirectory which can be used when writing a provider using the database's C or C++ API (for example the PostgreSQL or MySQL providers)the template in the
providers/skel-implementation/modelsdirectory which can be used when writing a provider for a system which is not a relational database (or does offer a very limited API, such as for the MS Access or Berkeley DB systems).
In any case, for example to create a DummyDb provider, follow these steps:
copy one of the template's directory into a new directory named
dummydbFrom inside that new directory, run the
providers/prepare_provider_sources.shscript with the name of the provider ("dummydb" here), the author's name and the author's email adress, which replaces all the class and object names with the name of the provider and renames the files correctly. These new sources should be compilable without any modification.Edit the
Makefile.amto add provider specific compilation and link flagsIntegrate the provider's new code into a compilation unit: either Libgda's sources in the
providersdirectory or in your own application (this step usually involves modifying theconfigure.acorconfigure.infiles).Implement the missing parts (it is usually a good idea to look how other provider's implementations are done to get ideas).
