diff options
Diffstat (limited to 'lib/impure/db_mysql.nim')
-rw-r--r-- | lib/impure/db_mysql.nim | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/impure/db_mysql.nim b/lib/impure/db_mysql.nim index 510503a63..c96829830 100644 --- a/lib/impure/db_mysql.nim +++ b/lib/impure/db_mysql.nim @@ -88,6 +88,8 @@ import strutils, mysql import db_common export db_common +import std/private/since + type DbConn* = distinct PMySQL ## encapsulates a database connection Row* = seq[string] ## a row of a dataset. NULL database values will be @@ -359,6 +361,19 @@ proc insertId*(db: DbConn, query: SqlQuery, result = tryInsertID(db, query, args) if result < 0: dbError(db) +proc tryInsert*(db: DbConn, query: SqlQuery, pkName: string, + args: varargs[string, `$`]): int64 + {.tags: [WriteDbEffect], raises: [], since: (1, 3).} = + ## same as tryInsertID + tryInsertID(db, query, args) + +proc insert*(db: DbConn, query: SqlQuery, pkName: string, + args: varargs[string, `$`]): int64 + {.tags: [WriteDbEffect], since: (1, 3).} = + ## same as insertId + result = tryInsert(db, query,pkName, args) + if result < 0: dbError(db) + proc execAffectedRows*(db: DbConn, query: SqlQuery, args: varargs[string, `$`]): int64 {. tags: [ReadDbEffect, WriteDbEffect].} = |