This commit is contained in:
Araq 2019-01-13 14:08:49 +01:00
commit 7f0559b93f

View file

@ -166,9 +166,11 @@ iterator fastRows*(db: DbConn, query: SqlQuery,
var stmt = setupQuery(db, query, args) var stmt = setupQuery(db, query, args)
var L = (column_count(stmt)) var L = (column_count(stmt))
var result = newRow(L) var result = newRow(L)
try:
while step(stmt) == SQLITE_ROW: while step(stmt) == SQLITE_ROW:
setRow(stmt, result, L) setRow(stmt, result, L)
yield result yield result
finally:
if finalize(stmt) != SQLITE_OK: dbError(db) if finalize(stmt) != SQLITE_OK: dbError(db)
iterator instantRows*(db: DbConn, query: SqlQuery, iterator instantRows*(db: DbConn, query: SqlQuery,
@ -177,8 +179,10 @@ iterator instantRows*(db: DbConn, query: SqlQuery,
## same as fastRows but returns a handle that can be used to get column text ## 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 iterator body. ## on demand using []. Returned handle is valid only within the iterator body.
var stmt = setupQuery(db, query, args) var stmt = setupQuery(db, query, args)
try:
while step(stmt) == SQLITE_ROW: while step(stmt) == SQLITE_ROW:
yield stmt yield stmt
finally:
if finalize(stmt) != SQLITE_OK: dbError(db) if finalize(stmt) != SQLITE_OK: dbError(db)
proc toTypeKind(t: var DbType; x: int32) = proc toTypeKind(t: var DbType; x: int32) =
@ -210,8 +214,10 @@ iterator instantRows*(db: DbConn; columns: var DbColumns; query: SqlQuery,
## on demand using []. Returned handle is valid only within the iterator body. ## on demand using []. Returned handle is valid only within the iterator body.
var stmt = setupQuery(db, query, args) var stmt = setupQuery(db, query, args)
setColumns(columns, stmt) setColumns(columns, stmt)
try:
while step(stmt) == SQLITE_ROW: while step(stmt) == SQLITE_ROW:
yield stmt yield stmt
finally:
if finalize(stmt) != SQLITE_OK: dbError(db) if finalize(stmt) != SQLITE_OK: dbError(db)
proc `[]`*(row: InstantRow, col: int32): string {.inline.} = proc `[]`*(row: InstantRow, col: int32): string {.inline.} =