From cb10f306561319f3bc604dee924a5af7639d6434 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Wed, 16 Dec 2015 19:18:59 +0100 Subject: big update for the db*.nim modules; uses new db_common.nim --- lib/impure/db_postgres.nim | 87 ++++++++++++++++++++-------------------------- 1 file changed, 37 insertions(+), 50 deletions(-) (limited to 'lib/impure/db_postgres.nim') diff --git a/lib/impure/db_postgres.nim b/lib/impure/db_postgres.nim index 5603d9686..802efb71f 100644 --- a/lib/impure/db_postgres.nim +++ b/lib/impure/db_postgres.nim @@ -62,47 +62,28 @@ ## "Dominik") import strutils, postgres +import db_common +export db_common + type DbConn* = PPGconn ## encapsulates a database connection Row* = seq[string] ## a row of a dataset. NULL database values will be - ## transformed always to the empty string. + ## transformed always to the empty string. InstantRow* = tuple[res: PPGresult, line: int32] ## a handle that can be ## used to get a row's ## column text on demand - EDb* = object of IOError ## exception that is raised if a database error occurs - - SqlQuery* = distinct string ## an SQL query string SqlPrepared* = distinct string ## a identifier for the prepared queries - FDb* = object of IOEffect ## effect that denotes a database operation - FReadDb* = object of FDb ## effect that denotes a read operation - FWriteDb* = object of FDb ## effect that denotes a write operation -{.deprecated: [TRow: Row, TSqlQuery: SqlQuery, TDbConn: DbConn, +{.deprecated: [TRow: Row, TDbConn: DbConn, TSqlPrepared: SqlPrepared].} -proc sql*(query: string): SqlQuery {.noSideEffect, inline.} = - ## constructs a SqlQuery from the string `query`. This is supposed to be - ## used as a raw-string-literal modifier: - ## ``sql"update user set counter = counter + 1"`` - ## - ## If assertions are turned off, it does nothing. If assertions are turned - ## on, later versions will check the string for valid syntax. - result = SqlQuery(query) - proc dbError*(db: DbConn) {.noreturn.} = - ## raises an EDb exception. - var e: ref EDb + ## raises a DbError exception. + var e: ref DbError new(e) e.msg = $pqErrorMessage(db) raise e -proc dbError*(msg: string) {.noreturn.} = - ## raises an EDb exception with message `msg`. - var e: ref EDb - new(e) - e.msg = msg - raise e - proc dbQuote*(s: string): string = ## DB quotes the string. result = "'" @@ -127,7 +108,7 @@ proc dbFormat(formatstr: SqlQuery, args: varargs[string]): string = add(result, c) proc tryExec*(db: DbConn, query: SqlQuery, - args: varargs[string, `$`]): bool {.tags: [FReadDB, FWriteDb].} = + args: varargs[string, `$`]): bool {.tags: [ReadDbEffect, WriteDbEffect].} = ## tries to execute the query and returns true if successful, false otherwise. var res = pqexecParams(db, dbFormat(query, args), 0, nil, nil, nil, nil, 0) @@ -135,7 +116,8 @@ proc tryExec*(db: DbConn, query: SqlQuery, pqclear(res) proc tryExec*(db: DbConn, stmtName: SqlPrepared, - args: varargs[string, `$`]): bool {.tags: [FReadDB, FWriteDb].} = + args: varargs[string, `$`]): bool {.tags: [ + ReadDbEffect, WriteDbEffect].} = ## tries to execute the query and returns true if successful, false otherwise. var arr = allocCStringArray(args) var res = pqexecPrepared(db, stmtName.string, int32(args.len), arr, @@ -145,7 +127,7 @@ proc tryExec*(db: DbConn, stmtName: SqlPrepared, pqclear(res) proc exec*(db: DbConn, query: SqlQuery, args: varargs[string, `$`]) {. - tags: [FReadDB, FWriteDb].} = + tags: [ReadDbEffect, WriteDbEffect].} = ## executes the query and raises EDB if not successful. var res = pqexecParams(db, dbFormat(query, args), 0, nil, nil, nil, nil, 0) @@ -153,7 +135,7 @@ proc exec*(db: DbConn, query: SqlQuery, args: varargs[string, `$`]) {. pqclear(res) proc exec*(db: DbConn, stmtName: SqlPrepared, - args: varargs[string]) {.tags: [FReadDB, FWriteDb].} = + args: varargs[string]) {.tags: [ReadDbEffect, WriteDbEffect].} = var arr = allocCStringArray(args) var res = pqexecPrepared(db, stmtName.string, int32(args.len), arr, nil, nil, 0) @@ -196,7 +178,7 @@ proc setRow(res: PPGresult, r: var Row, line, cols: int32) = add(r[col], x) iterator fastRows*(db: DbConn, query: SqlQuery, - args: varargs[string, `$`]): Row {.tags: [FReadDB].} = + args: varargs[string, `$`]): Row {.tags: [ReadDbEffect].} = ## executes the query and iterates over the result dataset. This is very ## fast, but potenially dangerous: If the for-loop-body executes another ## query, the results can be undefined. For Postgres it is safe though. @@ -209,7 +191,7 @@ iterator fastRows*(db: DbConn, query: SqlQuery, pqclear(res) iterator fastRows*(db: DbConn, stmtName: SqlPrepared, - args: varargs[string, `$`]): Row {.tags: [FReadDB].} = + args: varargs[string, `$`]): Row {.tags: [ReadDbEffect].} = ## executes the prepared query and iterates over the result dataset. var res = setupQuery(db, stmtName, args) var L = pqNfields(res) @@ -221,9 +203,9 @@ iterator fastRows*(db: DbConn, stmtName: SqlPrepared, iterator instantRows*(db: DbConn, query: SqlQuery, args: varargs[string, `$`]): InstantRow - {.tags: [FReadDb].} = + {.tags: [ReadDbEffect].} = ## same as fastRows but returns a handle that can be used to get column text - ## on demand using []. Returned handle is valid only within interator body. + ## on demand using []. Returned handle is valid only within iterator body. var res = setupQuery(db, query, args) for i in 0..pqNtuples(res)-1: yield (res: res, line: i) @@ -231,9 +213,9 @@ iterator instantRows*(db: DbConn, query: SqlQuery, iterator instantRows*(db: DbConn, stmtName: SqlPrepared, args: varargs[string, `$`]): InstantRow - {.tags: [FReadDb].} = + {.tags: [ReadDbEffect].} = ## same as fastRows but returns a handle that can be used to get column text - ## on demand using []. Returned handle is valid only within interator body. + ## on demand using []. Returned handle is valid only within iterator body. var res = setupQuery(db, stmtName, args) for i in 0..pqNtuples(res)-1: yield (res: res, line: i) @@ -248,7 +230,7 @@ proc len*(row: InstantRow): int32 {.inline.} = pqNfields(row.res) proc getRow*(db: DbConn, query: SqlQuery, - args: varargs[string, `$`]): Row {.tags: [FReadDB].} = + args: varargs[string, `$`]): Row {.tags: [ReadDbEffect].} = ## retrieves a single row. If the query doesn't return any rows, this proc ## will return a Row with empty strings for each column. var res = setupQuery(db, query, args) @@ -258,7 +240,7 @@ proc getRow*(db: DbConn, query: SqlQuery, pqclear(res) proc getRow*(db: DbConn, stmtName: SqlPrepared, - args: varargs[string, `$`]): Row {.tags: [FReadDB].} = + args: varargs[string, `$`]): Row {.tags: [ReadDbEffect].} = var res = setupQuery(db, stmtName, args) var L = pqNfields(res) result = newRow(L) @@ -266,31 +248,34 @@ proc getRow*(db: DbConn, stmtName: SqlPrepared, pqClear(res) proc getAllRows*(db: DbConn, query: SqlQuery, - args: varargs[string, `$`]): seq[Row] {.tags: [FReadDB].} = + args: varargs[string, `$`]): seq[Row] {. + tags: [ReadDbEffect].} = ## executes the query and returns the whole result dataset. result = @[] for r in fastRows(db, query, args): result.add(r) proc getAllRows*(db: DbConn, stmtName: SqlPrepared, - args: varargs[string, `$`]): seq[Row] {.tags: [FReadDB].} = + args: varargs[string, `$`]): seq[Row] {.tags: + [ReadDbEffect].} = ## executes the prepared query and returns the whole result dataset. result = @[] for r in fastRows(db, stmtName, args): result.add(r) iterator rows*(db: DbConn, query: SqlQuery, - args: varargs[string, `$`]): Row {.tags: [FReadDB].} = + args: varargs[string, `$`]): Row {.tags: [ReadDbEffect].} = ## same as `fastRows`, but slower and safe. for r in items(getAllRows(db, query, args)): yield r iterator rows*(db: DbConn, stmtName: SqlPrepared, - args: varargs[string, `$`]): Row {.tags: [FReadDB].} = + args: varargs[string, `$`]): Row {.tags: [ReadDbEffect].} = ## same as `fastRows`, but slower and safe. for r in items(getAllRows(db, stmtName, args)): yield r proc getValue*(db: DbConn, query: SqlQuery, - args: varargs[string, `$`]): string {.tags: [FReadDB].} = + args: varargs[string, `$`]): string {. + tags: [ReadDbEffect].} = ## executes the query and returns the first column of the first row of the ## result dataset. Returns "" if the dataset contains no rows or the database ## value is NULL. @@ -298,7 +283,8 @@ proc getValue*(db: DbConn, query: SqlQuery, result = if isNil(x): "" else: $x proc tryInsertID*(db: DbConn, query: SqlQuery, - args: varargs[string, `$`]): int64 {.tags: [FWriteDb].}= + args: varargs[string, `$`]): int64 {. + tags: [WriteDbEffect].}= ## executes the query (typically "INSERT") and returns the ## generated ID for the row or -1 in case of an error. For Postgre this adds ## ``RETURNING id`` to the query, so it only works if your primary key is @@ -311,7 +297,8 @@ proc tryInsertID*(db: DbConn, query: SqlQuery, result = -1 proc insertID*(db: DbConn, query: SqlQuery, - args: varargs[string, `$`]): int64 {.tags: [FWriteDb].} = + args: varargs[string, `$`]): int64 {. + tags: [WriteDbEffect].} = ## executes the query (typically "INSERT") and returns the ## generated ID for the row. For Postgre this adds ## ``RETURNING id`` to the query, so it only works if your primary key is @@ -321,7 +308,7 @@ proc insertID*(db: DbConn, query: SqlQuery, proc execAffectedRows*(db: DbConn, query: SqlQuery, args: varargs[string, `$`]): int64 {.tags: [ - FReadDB, FWriteDb].} = + ReadDbEffect, WriteDbEffect].} = ## executes the query (typically "UPDATE") and returns the ## number of affected rows. var q = dbFormat(query, args) @@ -332,7 +319,7 @@ proc execAffectedRows*(db: DbConn, query: SqlQuery, proc execAffectedRows*(db: DbConn, stmtName: SqlPrepared, args: varargs[string, `$`]): int64 {.tags: [ - FReadDB, FWriteDb].} = + ReadDbEffect, WriteDbEffect].} = ## executes the query (typically "UPDATE") and returns the ## number of affected rows. var arr = allocCStringArray(args) @@ -343,12 +330,12 @@ proc execAffectedRows*(db: DbConn, stmtName: SqlPrepared, result = parseBiggestInt($pqcmdTuples(res)) pqclear(res) -proc close*(db: DbConn) {.tags: [FDb].} = +proc close*(db: DbConn) {.tags: [DbEffect].} = ## closes the database connection. if db != nil: pqfinish(db) proc open*(connection, user, password, database: string): DbConn {. - tags: [FDb].} = + tags: [DbEffect].} = ## opens a database connection. Raises `EDb` if the connection could not ## be established. ## @@ -370,7 +357,7 @@ proc open*(connection, user, password, database: string): DbConn {. if pqStatus(result) != CONNECTION_OK: dbError(result) # result = nil proc setEncoding*(connection: DbConn, encoding: string): bool {. - tags: [FDb].} = + tags: [DbEffect].} = ## sets the encoding of a database connection, returns true for ## success, false for failure. return pqsetClientEncoding(connection, encoding) == 0 -- cgit 1.4.1-2-gfad0 From a3c8bb93760e258de406572f6181aa18fc88e7c3 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Wed, 16 Dec 2015 21:24:13 +0100 Subject: updated db*.nim modules --- lib/impure/db_mysql.nim | 2 +- lib/impure/db_odbc.nim | 83 ++++++++++++++++++---------------------------- lib/impure/db_postgres.nim | 2 +- lib/impure/db_sqlite.nim | 2 +- 4 files changed, 36 insertions(+), 53 deletions(-) (limited to 'lib/impure/db_postgres.nim') diff --git a/lib/impure/db_mysql.nim b/lib/impure/db_mysql.nim index ca99636f6..0a57f8a41 100644 --- a/lib/impure/db_mysql.nim +++ b/lib/impure/db_mysql.nim @@ -49,7 +49,7 @@ export db_common type DbConn* = PMySQL ## encapsulates a database connection Row* = seq[string] ## a row of a dataset. NULL database values will be - ## transformed always to the empty string. + ## converted to nil. InstantRow* = tuple[row: cstringArray, len: int] ## a handle that can be ## used to get a row's ## column text on demand diff --git a/lib/impure/db_odbc.nim b/lib/impure/db_odbc.nim index d7038303c..6af69d842 100644 --- a/lib/impure/db_odbc.nim +++ b/lib/impure/db_odbc.nim @@ -1,8 +1,12 @@ # +# +# Nim's Runtime Library +# (c) Copyright 2015 Nim Contributors +# # See the file "copying.txt", included in this # distribution, for details about the copyright. # -# + ## A higher level `ODBC` database wrapper. ## ## This is the same interface that is implemented for other databases. @@ -45,46 +49,32 @@ import strutils, odbcsql +import db_common +export db_common + type OdbcConnTyp = tuple[hDb: SqlHDBC, env: SqlHEnv, stmt: SqlHStmt] DbConn* = OdbcConnTyp ## encapsulates a database connection Row* = seq[string] ## a row of a dataset. NULL database values will be - ## transformed always to the empty string. + ## converted to nil. InstantRow* = tuple[row: seq[string], len: int] ## a handle that can be ## used to get a row's ## column text on demand - EDb* = object of IOError ## exception that is raised if a database error occurs - SqlQuery* = distinct string ## an SQL query string - - FDb* = object of IOEffect ## effect that denotes a database operation - FReadDb* = object of FDb ## effect that denotes a read operation - FWriteDb* = object of FDb ## effect that denotes a write operation - FReadODBC* = object of FDb ## effect that denotes a read of ODBC driver - FWriteODBC* = object of FDb ## effect that denotes a write of ODBC driver {.deprecated: [TRow: Row, TSqlQuery: SqlQuery, TDbConn: DbConn].} var buf: array[0..4096, char] proc properFreeResult(hType: int, sqlres: var SqlHandle) {. - tags: [FWriteODBC], raises: [].} = + tags: [WriteDbEffect], raises: [].} = try: discard SQLFreeHandle(hType.TSqlSmallInt, sqlres) sqlres = nil except: discard -proc sql*(query: string): SqlQuery {.noSideEffect, inline.} = - ## Constructs a SqlQuery from the string `query`. This is supposed to be - ## used as a raw-string-literal modifier: - ## ``sql"update user set counter = counter + 1"`` - ## - ## If assertions are turned off, it does nothing. If assertions are turned - ## on, later versions will check the string for valid syntax. - result = SqlQuery(query) - proc getErrInfo(db: var DbConn): tuple[res: int, ss, ne, msg: string] {. - tags: [FReadODBC], raises: [].} = + tags: [ReadDbEffect], raises: [].} = ## Returns ODBC error information var sqlState: array[0..512, char] @@ -106,10 +96,10 @@ proc getErrInfo(db: var DbConn): tuple[res: int, ss, ne, msg: string] {. return (res.int, $sqlState, $nativeErr, $errMsg) proc dbError*(db: var DbConn) {. - tags: [FReadODBC,FWriteODBC], raises: [EDb] .} = - ## Raises an `[EDb]` exception with ODBC error information + tags: [ReadDbEffect, WriteDbEffect], raises: [DbError] .} = + ## Raises an `[DbError]` exception with ODBC error information var - e: ref EDb + e: ref DbError ss, ne, msg: string = "" isAnError = false res: int = 0 @@ -137,19 +127,12 @@ proc dbError*(db: var DbConn) {. properFreeResult(SQL_HANDLE_ENV, db.env) raise e -proc dbError*(msg: string) {.noreturn.} = - ## Raises an EDb exception with message `msg`. - var e: ref EDb - new(e) - e.msg = msg - raise e - -proc SqlCheck(db: var DbConn, resVal: TSqlSmallInt) {.raises: [EDb]} = +proc SqlCheck(db: var DbConn, resVal: TSqlSmallInt) {.raises: [DbError]} = ## Wrapper that checks if ``resVal`` is not SQL_SUCCESS and if so, raises [EDb] if resVal != SQL_SUCCESS: dbError(db) proc SqlGetDBMS(db: var DbConn): string {. - tags: [FReadODBC, FWriteODBC], raises: [] .} = + tags: [ReadDbEffect, WriteDbEffect], raises: [] .} = ## Returns the ODBC SQL_DBMS_NAME string const SQL_DBMS_NAME = 17.SqlUSmallInt @@ -188,7 +171,7 @@ proc dbFormat(formatstr: SqlQuery, args: varargs[string]): string {. proc prepareFetch(db: var DbConn, query: SqlQuery, args: varargs[string, `$`]) {. - tags: [FReadDb, FReadODBC, FWriteODBC], raises: [EDb].} = + tags: [ReadDbEffect, WriteDbEffect], raises: [DbError].} = # Prepare a statement, execute it and fetch the data to the driver # ready for retrieval of the data # Used internally by iterators and retrieval procs @@ -203,7 +186,7 @@ proc prepareFetch(db: var DbConn, query: SqlQuery, proc prepareFetchDirect(db: var DbConn, query: SqlQuery, args: varargs[string, `$`]) {. - tags: [FReadDb, FWriteDb, FReadODBC, FWriteODBC], raises: [EDb].} = + tags: [ReadDbEffect, WriteDbEffect], raises: [DbError].} = # Prepare a statement, execute it and fetch the data to the driver # ready for retrieval of the data # Used internally by iterators and retrieval procs @@ -216,7 +199,7 @@ proc prepareFetchDirect(db: var DbConn, query: SqlQuery, db.SqlCheck(SQLFetch(db.stmt)) proc tryExec*(db: var DbConn, query: SqlQuery, args: varargs[string, `$`]): bool {. - tags: [FReadDB, FWriteDb, FReadODBC, FWriteODBC], raises: [].} = + tags: [ReadDbEffect, WriteDbEffect], raises: [].} = ## Tries to execute the query and returns true if successful, false otherwise. var res:TSqlSmallInt = -1 @@ -231,11 +214,11 @@ proc tryExec*(db: var DbConn, query: SqlQuery, args: varargs[string, `$`]): bool return res == SQL_SUCCESS proc rawExec(db: var DbConn, query: SqlQuery, args: varargs[string, `$`]) {. - tags: [FReadDb, FWriteDb, FReadODBC, FWriteODBC], raises: [EDb].} = + tags: [ReadDbEffect, WriteDbEffect], raises: [DbError].} = db.prepareFetchDirect(query, args) proc exec*(db: var DbConn, query: SqlQuery, args: varargs[string, `$`]) {. - tags: [FReadDb, FWriteDb, FReadODBC, FWriteODBC], raises: [EDb].} = + tags: [ReadDbEffect, WriteDbEffect], raises: [DbError].} = ## Executes the query and raises EDB if not successful. db.prepareFetchDirect(query, args) properFreeResult(SQL_HANDLE_STMT, db.stmt) @@ -246,7 +229,7 @@ proc newRow(L: int): Row {.noSideEFfect.} = iterator fastRows*(db: var DbConn, query: SqlQuery, args: varargs[string, `$`]): Row {. - tags: [FReadDB, FReadODBC, FWriteODBC], raises: [EDb].} = + tags: [ReadDbEffect, WriteDbEffect], raises: [DbError].} = ## Executes the query and iterates over the result dataset. ## ## This is very fast, but potentially dangerous. Use this iterator only @@ -278,7 +261,7 @@ iterator fastRows*(db: var DbConn, query: SqlQuery, iterator instantRows*(db: var DbConn, query: SqlQuery, args: varargs[string, `$`]): InstantRow - {.tags: [FReadDb, FReadODBC, FWriteODBC].} = + {.tags: [ReadDbEffect, WriteDbEffect].} = ## Same as fastRows but returns a handle that can be used to get column text ## on demand using []. Returned handle is valid only within the interator body. var @@ -310,7 +293,7 @@ proc len*(row: InstantRow): int {.inline.} = proc getRow*(db: var DbConn, query: SqlQuery, args: varargs[string, `$`]): Row {. - tags: [FReadDB, FReadODBC, FWriteODBC], raises: [EDb].} = + tags: [ReadDbEffect, WriteDbEffect], raises: [DbError].} = ## Retrieves a single row. If the query doesn't return any rows, this proc ## will return a Row with empty strings for each column. var @@ -331,7 +314,7 @@ proc getRow*(db: var DbConn, query: SqlQuery, proc getAllRows*(db: var DbConn, query: SqlQuery, args: varargs[string, `$`]): seq[Row] {. - tags: [FReadDB, FReadODBC, FWriteODBC], raises: [EDb].} = + tags: [ReadDbEffect, WriteDbEffect], raises: [DbError].} = ## Executes the query and returns the whole result dataset. var rowRes: Row @@ -355,7 +338,7 @@ proc getAllRows*(db: var DbConn, query: SqlQuery, iterator rows*(db: var DbConn, query: SqlQuery, args: varargs[string, `$`]): Row {. - tags: [FReadDB, FReadODBC, FWriteODBC], raises: [EDb].} = + tags: [ReadDbEffect, WriteDbEffect], raises: [DbError].} = ## Same as `fastRows`, but slower and safe. ## ## This retrieves ALL rows into memory before @@ -365,7 +348,7 @@ iterator rows*(db: var DbConn, query: SqlQuery, proc getValue*(db: var DbConn, query: SqlQuery, args: varargs[string, `$`]): string {. - tags: [FReadDB, FReadODBC, FWriteODBC], raises: [].} = + tags: [ReadDbEffect, WriteDbEffect], raises: [].} = ## Executes the query and returns the first column of the first row of the ## result dataset. Returns "" if the dataset contains no rows or the database ## value is NULL. @@ -376,7 +359,7 @@ proc getValue*(db: var DbConn, query: SqlQuery, proc tryInsertId*(db: var DbConn, query: SqlQuery, args: varargs[string, `$`]): int64 {. - tags: [FReadDb, FWriteDb, FReadODBC, FWriteODBC], raises: [].} = + tags: [ReadDbEffect, WriteDbEffect], raises: [].} = ## Executes the query (typically "INSERT") and returns the ## generated ID for the row or -1 in case of an error. if not tryExec(db, query, args): @@ -401,7 +384,7 @@ proc tryInsertId*(db: var DbConn, query: SqlQuery, proc insertId*(db: var DbConn, query: SqlQuery, args: varargs[string, `$`]): int64 {. - tags: [FReadDb, FWriteDb, FReadODBC, FWriteODBC], raises: [EDb].} = + tags: [ReadDbEffect, WriteDbEffect], raises: [DbError].} = ## Executes the query (typically "INSERT") and returns the ## generated ID for the row. result = tryInsertID(db, query, args) @@ -409,7 +392,7 @@ proc insertId*(db: var DbConn, query: SqlQuery, proc execAffectedRows*(db: var DbConn, query: SqlQuery, args: varargs[string, `$`]): int64 {. - tags: [FReadDB, FWriteDb, FReadODBC, FWriteODBC], raises: [EDb].} = + tags: [ReadDbEffect, WriteDbEffect], raises: [DbError].} = ## Runs the query (typically "UPDATE") and returns the ## number of affected rows result = -1 @@ -426,7 +409,7 @@ proc execAffectedRows*(db: var DbConn, query: SqlQuery, result = rCnt proc close*(db: var DbConn) {. - tags: [FWriteODBC], raises: [].} = + tags: [WriteDbEffect], raises: [].} = ## Closes the database connection. if db.hDb != nil: try: @@ -440,7 +423,7 @@ proc close*(db: var DbConn) {. discard proc open*(connection, user, password, database: string): DbConn {. - tags: [FReadODBC, FWriteODBC], raises: [EDb].} = + tags: [ReadDbEffect, WriteDbEffect], raises: [DbError].} = ## Opens a database connection. ## ## Raises `EDb` if the connection could not be established. @@ -471,7 +454,7 @@ proc open*(connection, user, password, database: string): DbConn {. result.dbError() proc setEncoding*(connection: DbConn, encoding: string): bool {. - tags: [FReadODBC, FWriteODBC], raises: [EDb].} = + tags: [ReadDbEffect, WriteDbEffect], raises: [DbError].} = ## Currently not implemented for ODBC. ## ## Sets the encoding of a database connection, returns true for diff --git a/lib/impure/db_postgres.nim b/lib/impure/db_postgres.nim index 802efb71f..9bdbae4c2 100644 --- a/lib/impure/db_postgres.nim +++ b/lib/impure/db_postgres.nim @@ -68,7 +68,7 @@ export db_common type DbConn* = PPGconn ## encapsulates a database connection Row* = seq[string] ## a row of a dataset. NULL database values will be - ## transformed always to the empty string. + ## converted to nil. InstantRow* = tuple[res: PPGresult, line: int32] ## a handle that can be ## used to get a row's ## column text on demand diff --git a/lib/impure/db_sqlite.nim b/lib/impure/db_sqlite.nim index 90a2f8728..17f031a52 100644 --- a/lib/impure/db_sqlite.nim +++ b/lib/impure/db_sqlite.nim @@ -48,7 +48,7 @@ export db_common type DbConn* = PSqlite3 ## encapsulates a database connection Row* = seq[string] ## a row of a dataset. NULL database values will be - ## transformed always to the empty string. + ## converted to nil. InstantRow* = Pstmt ## a handle that can be used to get a row's column ## text on demand {.deprecated: [TRow: Row, TDbConn: DbConn].} -- cgit 1.4.1-2-gfad0