diff options
Diffstat (limited to 'lib/impure')
-rw-r--r-- | lib/impure/db_mysql.nim | 4 | ||||
-rw-r--r-- | lib/impure/db_odbc.nim | 6 | ||||
-rw-r--r-- | lib/impure/db_postgres.nim | 4 | ||||
-rw-r--r-- | lib/impure/db_sqlite.nim | 8 |
4 files changed, 21 insertions, 1 deletions
diff --git a/lib/impure/db_mysql.nim b/lib/impure/db_mysql.nim index 9c24de33a..ba560243f 100644 --- a/lib/impure/db_mysql.nim +++ b/lib/impure/db_mysql.nim @@ -286,6 +286,10 @@ proc `[]`*(row: InstantRow, col: int): string {.inline.} = ## Returns text for given column of the row. $row.row[col] +proc unsafeColumnAt*(row: InstantRow, index: int): cstring {.inline.} = + ## Return cstring of given column of the row + row.row[index] + proc len*(row: InstantRow): int {.inline.} = ## Returns number of columns in the row. row.len diff --git a/lib/impure/db_odbc.nim b/lib/impure/db_odbc.nim index 4c33a5a82..7b59f8313 100644 --- a/lib/impure/db_odbc.nim +++ b/lib/impure/db_odbc.nim @@ -330,7 +330,11 @@ iterator instantRows*(db: var DbConn, query: SqlQuery, proc `[]`*(row: InstantRow, col: int): string {.inline.} = ## Returns text for given column of the row - row.row[col] + $row.row[col] + +proc unsafeColumnAt*(row: InstantRow, index: int): cstring {.inline.} = + ## Return cstring of given column of the row + row.row[index] proc len*(row: InstantRow): int {.inline.} = ## Returns number of columns in the row diff --git a/lib/impure/db_postgres.nim b/lib/impure/db_postgres.nim index ec804072f..45cd38daa 100644 --- a/lib/impure/db_postgres.nim +++ b/lib/impure/db_postgres.nim @@ -381,6 +381,10 @@ proc `[]`*(row: InstantRow; col: int): string {.inline.} = ## returns text for given column of the row $pqgetvalue(row.res, int32(row.line), int32(col)) +proc unsafeColumnAt*(row: InstantRow, index: int): cstring {.inline.} = + ## Return cstring of given column of the row + pqgetvalue(row.res, int32(row.line), int32(index)) + proc len*(row: InstantRow): int {.inline.} = ## returns number of columns in the row int(pqNfields(row.res)) diff --git a/lib/impure/db_sqlite.nim b/lib/impure/db_sqlite.nim index 9b714a778..b4ac22d38 100644 --- a/lib/impure/db_sqlite.nim +++ b/lib/impure/db_sqlite.nim @@ -359,6 +359,14 @@ proc `[]`*(row: InstantRow, col: int32): string {.inline.} = ## example code $column_text(row, col) +proc unsafeColumnAt*(row: InstantRow, index: int32): cstring {.inline.} = + ## Returns cstring for given column of the row. + ## + ## See also: + ## * `instantRows iterator <#instantRows.i,DbConn,SqlQuery,varargs[string,]>`_ + ## example code + column_text(row, index) + proc len*(row: InstantRow): int32 {.inline.} = ## Returns number of columns in a row. ## |