Home  +  Forums  +  C++ and Sockets  +  C++ and SQL: MySQL, sqlite, ODBC  +  Miscellaneous Projects
Logo
~Database~
~ C++ ~
~Contact~

MySQL wrapped

: another C++ wrapper for the MySQL C API

mysql devconnect member logo
[ About | Download | Examples | Class diagram | License ]

This is a C++ wrapper for the MySQL database C application programming interface. The code works for linux/unix, as well as win32. MySQL v5 is supported. Since version 1.5 the database connection pool can be made threadsafe.

This is free software, licensed under the GNU GPL.

Background

After pounding away miles of code using the C API of MySQL in my applications, I finally managed to put together a simple and naive C++ wrapper. The wrapper consists of two classes, one session control object ("Database") and one worker object ("Query"). The session control object contains a simple connection pool, so established database connections are reused in a sane manner. The worker object contains methods to execute sql queries alternatively store results from sql queries.

How to create the 'libmysqlwrapped.h' file

Sometimes the libmysqlwrapped.h file does not get created while building the library, so here's how to create it manually.

Win32

copy IError.h+StderrLog.h+SysLog.h+enum_t.h+set_t.h+Database.h+Query.h libmysqlwrapped.h

Unix

cat IError.h StderrLog.h SysLog.h enum_t.h set_t.h Database.h Query.h > libmysqlwrapped.h


Projects using this

  • s11n.net - the C++ serialization library

Links




Page, code, and content Copyright (C) 2021 by Anders Hedström