@@ -205,12 +205,14 @@ macro importdb*(sql: static string, body: untyped) =
205
205
error(" Expected proc or iterator, got " & $ body.kind, body)
206
206
return
207
207
208
- proc db_begin() {.importdb: " BEGIN" .}
208
+ proc db_begin_deferred() {.importdb: " BEGIN DEFERRED" .}
209
+ proc db_begin_immediate() {.importdb: " BEGIN IMMEDIATE" .}
210
+ proc db_begin_exclusive() {.importdb: " BEGIN EXCLUSIVE" .}
209
211
proc db_commit() {.importdb: " COMMIT" .}
210
212
proc db_rollback() {.importdb: " ROLLBACK" .}
211
213
212
- template transaction * (db: var Database, body: untyped ): untyped =
213
- db_begin db
214
+ template gen_transaction (db: var Database, begin_stmt , body: untyped ): untyped =
215
+ begin_stmt db
214
216
block outer:
215
217
template commit() {.inject, used.} =
216
218
db_commit db
@@ -225,3 +227,12 @@ template transaction*(db: var Database, body: untyped): untyped =
225
227
except :
226
228
db_rollback db
227
229
raise getCurrentException()
230
+
231
+ template transaction* (db: var Database, body: untyped ): untyped =
232
+ gen_transaction db, db_begin_deferred, body
233
+
234
+ template transactionImmediate* (db: var Database, body: untyped ): untyped =
235
+ gen_transaction db, db_begin_immediate, body
236
+
237
+ template transactionExclusive* (db: var Database, body: untyped ): untyped =
238
+ gen_transaction db, db_begin_exclusive, body
0 commit comments