20
20
* along with this program. If not, see <http://www.gnu.org/licenses/>.
23
#include <sqlite3cc/connection.h>
23
#include <sqlite3cc/database.h>
24
24
#include <sqlite3cc/exception.h>
27
sqlite::connection::mutex_guard::mutex_guard(
28
connection &connection )
30
_mutex( sqlite3_db_mutex( connection._handle ) )
32
if( _mutex ) sqlite3_mutex_enter( _mutex );
36
sqlite::connection::mutex_guard::~mutex_guard()
41
void sqlite::connection::mutex_guard::leave()
44
sqlite3_mutex_leave( _mutex );
50
sqlite::connection::connection(
27
sqlite::database::database(
51
28
const std::string &filename )
55
int code = open( filename );
56
if( code != SQLITE_OK ) throw sqlite_error( *this, code );
32
int error_code = open( filename );
33
if( error_code != SQLITE_OK ) throw sqlite_error( error_code );
60
sqlite::connection::connection()
37
sqlite::database::database()
67
sqlite::connection::~connection()
44
sqlite::database::~database()
73
int sqlite::connection::open(
50
int sqlite::database::open(
74
51
const std::string &filename,
91
void sqlite::connection::exec(
68
int sqlite::database::exec(
92
69
const std::string &sql )
94
int code = sqlite3_exec( _handle, sql.c_str(), NULL, NULL, NULL );
95
if( code != SQLITE_OK ) throw sqlite_error( *this, code );
71
return sqlite3_exec( _handle, sql.c_str(), NULL, NULL, NULL );
99
int sqlite::connection::busy_timeout(
75
int sqlite::database::busy_timeout(
102
78
return sqlite3_busy_timeout( _handle, duration );