About DBIC++

What is dbic++ ?

dbic++ is a database client library written in C++ which comes with support for the following databases,

  • PostgreSQL >= 8.3
  • MySQL >= 5.0
  • SQLite >= 3.7

Main Features

  • Simple and fast.
  • Support for PostgreSQL, MySQL and SQLite3.
  • Nested transactions.
  • API for async queries (PostgreSQL and MySQL).

Source

Clone the repository from github and have fun!

Installing

Read the instructions on github.

Reading

At the very least you need to know how AbstractHandle, AbstractStatement, Handle, and Statement work.  It is also recommended that you read through documentation on Param.

Examples

Checkout Handle or StringIO for some quick examples. dbic++ source distribution also contains some examples that can be found under src/examples/.

To compile code that uses dbic++, use pkg-config to get the correct compiler flags.

g++ `pkg-config --libs --cflags dbic++` -o myprogram myprogram.cc

Benchmarks

You can run these yourself if you’re keen.  The makefile might need some tweaks on non-debian based distributions.  The following results were obtained on a Core2DUO 2.53GHz, 4GB, 5200rpm drive with stock database configs.

  • The dataset size is 50 rows of 3 fields (id, text, timestamp)
  • 10000 SELECT queries run back to back, fetching all rows and printing them.
cd bench/ && make

./benchmarks.sh

+ Setting up sample data (50 rows)
  * mysql
  * postgresql
+ Done

./benchmarks.sh -w bench -n10000

+ Benchmarking mysql

  * mysql      user 0.69 sys 0.21 real 2.34
  * mysql++    user 1.06 sys 0.09 real 2.74
  * dbic++     user 0.81 sys 0.25 real 2.58

+ Benchmarking postgresql

  * pq         user 0.42 sys 0.14 real 2.01
  * dbic++     user 0.49 sys 0.12 real 2.05

+ Finished
class AbstractHandle
Pure virtual class that defines the api that individual database drivers need to support.
class AbstractStatement
Pure virtual class that defines the api that individual database drivers need to support.
class Handle
Facade for AbstractHandle.
class Statement
Facade for AbstractStatement, you should be using this for most of the normal work.
struct Param
Encapsulates a value in string or binary format.
class StringIO : public IO
Concrete implementation of IO that can handle string data.
Close
Fork me on GitHub