added db_*.getRow

This commit is contained in:
Araq
2012-04-24 08:44:36 +02:00
parent 7e7c514dfc
commit afd8ca2f15
6 changed files with 42 additions and 4 deletions

View File

@@ -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.
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
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
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.

View File

@@ -99,6 +99,21 @@ iterator FastRows*(db: TDbConn, query: TSqlQuery,
yield result
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,
args: openarray[string]): seq[TRow] =
## executes the query and returns the whole result dataset.

View File

@@ -103,6 +103,15 @@ iterator FastRows*(db: TDbConn, query: TSqlQuery,
yield result
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,
args: openarray[string]): seq[TRow] =
## executes the query and returns the whole result dataset.

View File

@@ -101,6 +101,16 @@ iterator FastRows*(db: TDbConn, query: TSqlQuery,
yield result
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,
args: openarray[string]): seq[TRow] =
## executes the query and returns the whole result dataset.

View File

@@ -10,14 +10,14 @@ version 0.9.0
- Test capture of for loop vars; test generics;
- test constant closures
- 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
- unsigned ints and bignums; requires abstract integer literal type:
use tyInt+node for that
- implement the high level optimizer
- change overloading resolution
- implement proper coroutines
- ``hoist`` pragma for loop hoisting
- we need to support iteration of 2 different data structures in parallel
- make exceptions compatible with C++ exceptions

View File

@@ -42,6 +42,7 @@ Library Additions
values of an enum.
- Added ``system.TInteger`` and ``system.TNumber`` type classes matching
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``
and ``GC_step`` procs.