[racket] racket/db: fetching multiple rows with multiple columns in a "for" loop

From: Dmitry Pavlov (dpavlov at ipa.nw.ru)
Date: Tue Feb 5 11:57:29 EST 2013

Hello,

Suppose I have the following code:

(define conn (sqlite3-connect #:database "mydb.db" ))

(for (((x y) (in-query c "SELECT X, Y FROM DATA")))
     (displayln x) (displayln y))

in-query returns a sequence that gives two values
at one call, and the "for" loop binds those values
to x and y respectively, and everything works fine.

Suppose then that I use an SELECT statement instrumented
in runtime, and that I do not know beforehand how many
values am I selecting. How do I get a list or a vector
of my values per each row?

It seems that I can not bind unknown number of
values in a "for" loop, can I?

Ideally, I would like a sequence that returns a list
(or a vector) of column values at each call.
query-row is close to what I need, but it can be used
only if I have only one row, so no sequence.

Any hints will be much appreciated.

Best regards,

Dmitry

Posted on the users mailing list.