MyMySQL is a very lightweight wrapper for the MySQL C client API, which manages all resources internally.
The overhead due to the wrapper should be very low, as all functions are inline and most simply forward to the MySQL C API functions.
No exceptions are thrown by any part of the library, so it is suitable to use in code that doesn't use exceptions.
Example of use:
mymysql::Connection db; db.user("db_user").database("test_db"); db.options().setConnectTimeout(600).readDefaultGroup("my_conf_grp"); if (db.open("my_rubbish_password")) { std::ostringstream sql; sql << "INSERT INTO tbl_name (col_name) ('" << mymysql::escape(db, "This text's going to be escaped") << "'), ('" << mymysql::escape(db, "\\ \" ' \0") << "')"; mymysql::Query q(db, sql.str()); if (q.errnum()) { std::cerr << "Insert failed: " << q.error() << std::endl; } else { if (q.run("SELECT col_name FROM tbl_name")) { for (mymysql::Query::iterator i = q.begin(); i != q.end(); ++i) { std::cout << (*i)[0] << std::endl; } } else { std::cerr << "Select failed: " << q.error() << std::endl; } } } else { std::cerr << "Connect failed: " << db.error() << std::endl; }
1.3.4