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