added db_*.getRow
This commit is contained in:
parent
7e7c514dfc
commit
afd8ca2f15
6 changed files with 42 additions and 4 deletions
|
|
@ -22,7 +22,10 @@ The GC is only triggered in a memory allocation operation. It it not triggered
|
||||||
by some timer and does not run in a background thread.
|
by some timer and does not run in a background thread.
|
||||||
|
|
||||||
The cycle collector can be en-/disabled independently from the other parts of
|
The cycle collector can be en-/disabled independently from the other parts of
|
||||||
the GC with ``GC_enableMarkAndSweep`` and ``GC_disableMarkAndSweep``.
|
the GC with ``GC_enableMarkAndSweep`` and ``GC_disableMarkAndSweep``. The
|
||||||
|
compiler analyses the types for their possibility to build cycles, but often
|
||||||
|
it is necessary to help this analysis with the ``acyclic`` pragma (see
|
||||||
|
`acyclic <manual.html#acyclic-pragma>`_ for further information).
|
||||||
|
|
||||||
To force a full collection call ``GC_fullCollect``. Note that it is generally
|
To force a full collection call ``GC_fullCollect``. Note that it is generally
|
||||||
better to let the GC do its work and not enforce a full collection.
|
better to let the GC do its work and not enforce a full collection.
|
||||||
|
|
@ -79,7 +82,7 @@ uses microseconds for convenience.
|
||||||
|
|
||||||
|
|
||||||
Define the symbol ``reportMissedDeadlines`` to make the GC output whenever it
|
Define the symbol ``reportMissedDeadlines`` to make the GC output whenever it
|
||||||
missed a deadline. The reporting will be enhances and supported by the API in
|
missed a deadline. The reporting will be enhanced and supported by the API in
|
||||||
later versions of the collector.
|
later versions of the collector.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,21 @@ iterator FastRows*(db: TDbConn, query: TSqlQuery,
|
||||||
yield result
|
yield result
|
||||||
properFreeResult(sqlres, row)
|
properFreeResult(sqlres, row)
|
||||||
|
|
||||||
|
proc getRow*(db: TDbConn, query: TSqlQuery,
|
||||||
|
args: openarray[string]): TRow =
|
||||||
|
## retrieves a single row.
|
||||||
|
Exec(db, query, args)
|
||||||
|
var sqlres = mysql.UseResult(db)
|
||||||
|
if sqlres != nil:
|
||||||
|
var L = int(mysql.NumFields(sqlres))
|
||||||
|
var result = newRow(L)
|
||||||
|
var row = mysql.FetchRow(sqlres)
|
||||||
|
if row != nil:
|
||||||
|
for i in 0..L-1:
|
||||||
|
setLen(result[i], 0)
|
||||||
|
add(result[i], row[i])
|
||||||
|
properFreeResult(sqlres, row)
|
||||||
|
|
||||||
proc GetAllRows*(db: TDbConn, query: TSqlQuery,
|
proc GetAllRows*(db: TDbConn, query: TSqlQuery,
|
||||||
args: openarray[string]): seq[TRow] =
|
args: openarray[string]): seq[TRow] =
|
||||||
## executes the query and returns the whole result dataset.
|
## executes the query and returns the whole result dataset.
|
||||||
|
|
|
||||||
|
|
@ -103,6 +103,15 @@ iterator FastRows*(db: TDbConn, query: TSqlQuery,
|
||||||
yield result
|
yield result
|
||||||
PQclear(res)
|
PQclear(res)
|
||||||
|
|
||||||
|
proc getRow*(db: TDbConn, query: TSqlQuery,
|
||||||
|
args: openarray[string]): TRow =
|
||||||
|
## retrieves a single row.
|
||||||
|
var res = setupQuery(db, query, args)
|
||||||
|
var L = int(PQnfields(res))
|
||||||
|
var result = newRow(L)
|
||||||
|
setRow(res, result, 0, L)
|
||||||
|
PQclear(res)
|
||||||
|
|
||||||
proc GetAllRows*(db: TDbConn, query: TSqlQuery,
|
proc GetAllRows*(db: TDbConn, query: TSqlQuery,
|
||||||
args: openarray[string]): seq[TRow] =
|
args: openarray[string]): seq[TRow] =
|
||||||
## executes the query and returns the whole result dataset.
|
## executes the query and returns the whole result dataset.
|
||||||
|
|
|
||||||
|
|
@ -101,6 +101,16 @@ iterator FastRows*(db: TDbConn, query: TSqlQuery,
|
||||||
yield result
|
yield result
|
||||||
if finalize(stmt) != SQLITE_OK: dbError(db)
|
if finalize(stmt) != SQLITE_OK: dbError(db)
|
||||||
|
|
||||||
|
proc getRow*(db: TDbConn, query: TSqlQuery,
|
||||||
|
args: openarray[string]): TRow =
|
||||||
|
## retrieves a single row.
|
||||||
|
var stmt = setupQuery(db, query, args)
|
||||||
|
var L = int(columnCount(stmt))
|
||||||
|
var result = newRow(L)
|
||||||
|
if step(stmt) == SQLITE_ROW:
|
||||||
|
setRow(stmt, result, L)
|
||||||
|
if finalize(stmt) != SQLITE_OK: dbError(db)
|
||||||
|
|
||||||
proc GetAllRows*(db: TDbConn, query: TSqlQuery,
|
proc GetAllRows*(db: TDbConn, query: TSqlQuery,
|
||||||
args: openarray[string]): seq[TRow] =
|
args: openarray[string]): seq[TRow] =
|
||||||
## executes the query and returns the whole result dataset.
|
## executes the query and returns the whole result dataset.
|
||||||
|
|
|
||||||
4
todo.txt
4
todo.txt
|
|
@ -10,14 +10,14 @@ version 0.9.0
|
||||||
- Test capture of for loop vars; test generics;
|
- Test capture of for loop vars; test generics;
|
||||||
- test constant closures
|
- test constant closures
|
||||||
- implement closures that support nesting > 1
|
- implement closures that support nesting > 1
|
||||||
|
- implement proper coroutines
|
||||||
|
|
||||||
- document and fix 'do' notation
|
- document 'do' notation
|
||||||
- dead code elim for JS backend; 'of' operator for JS backend
|
- dead code elim for JS backend; 'of' operator for JS backend
|
||||||
- unsigned ints and bignums; requires abstract integer literal type:
|
- unsigned ints and bignums; requires abstract integer literal type:
|
||||||
use tyInt+node for that
|
use tyInt+node for that
|
||||||
- implement the high level optimizer
|
- implement the high level optimizer
|
||||||
- change overloading resolution
|
- change overloading resolution
|
||||||
- implement proper coroutines
|
|
||||||
- ``hoist`` pragma for loop hoisting
|
- ``hoist`` pragma for loop hoisting
|
||||||
- we need to support iteration of 2 different data structures in parallel
|
- we need to support iteration of 2 different data structures in parallel
|
||||||
- make exceptions compatible with C++ exceptions
|
- make exceptions compatible with C++ exceptions
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ Library Additions
|
||||||
values of an enum.
|
values of an enum.
|
||||||
- Added ``system.TInteger`` and ``system.TNumber`` type classes matching
|
- Added ``system.TInteger`` and ``system.TNumber`` type classes matching
|
||||||
any of the corresponding type available in nimrod.
|
any of the corresponding type available in nimrod.
|
||||||
|
- Added ``system.clamp`` to limit a value within an interval ``[a, b]``.
|
||||||
- The GC supports (soft) realtime systems via ``GC_setMaxPause``
|
- The GC supports (soft) realtime systems via ``GC_setMaxPause``
|
||||||
and ``GC_step`` procs.
|
and ``GC_step`` procs.
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue