@@ -21,10 +21,11 @@ */ #import "SL3Connection.h" #import "SL3PreparedStatement.h" +#import "SL3ExecuteStatementFailedException.h" #import "SL3OpenFailedException.h" @implementation SL3Connection + (instancetype)connectionWithPath: (OFString *)path { @@ -48,11 +49,12 @@ flags: (int)flags { self = [super init]; @try { - int code = sqlite3_open_v2(path.UTF8String, &_db, flags, NULL); + int code = sqlite3_open_v2(path.UTF8String, &_conn, flags, + NULL); if (code != SQLITE_OK) @throw [SL3OpenFailedException exceptionWithPath: path flags: flags errorCode: code]; @@ -64,11 +66,11 @@ return self; } - (void)dealloc { - sqlite3_close(_db); + sqlite3_close(_conn); [super dealloc]; } - (SL3PreparedStatement *)prepareStatement: (OFConstantString *)SQL @@ -75,6 +77,16 @@ { return [[[SL3PreparedStatement alloc] sl3_initWithConnection: self SQLStatement: SQL] autorelease]; } + +- (void)executeStatement: (OFConstantString *)SQL +{ + int code = sqlite3_exec(_conn, SQL.UTF8String, NULL, NULL, NULL); + + if (code != SQLITE_OK) + @throw [SL3ExecuteStatementFailedException + exceptionWithConnection: self + errorCode: code]; +} @end