[racket] db library and cursors

From: Ryan Culpepper (ryan at cs.utah.edu)
Date: Wed Jul 25 18:35:19 EDT 2012

On 07/25/2012 06:13 PM, Neil Van Dyke wrote:
> Any thoughts on whether the "db" library will support cursors? Or
> thoughts on handling large query results in the "db" library?
> Reason I ask: I'm experimentally reimplementing an older PostgreSQL
> library to use the Racket "db" library. Some applications using this
> library use cursors for large query results. In the Racket 5.2.1 source
> code, it looks like even "in-query" sucks all the query result rows into
> a non-lazy list. I can make a "cursor" object that simply wraps a
> non-lazy list of results, but this could be a problem for large query
> results.

Basic cursor support has been in db for a couple months (and will be in 
5.3). There's no cursor object per se. Instead, if you call 'in-query' 
with a finite value for the #:fetch argument, it fetches only that many 
rows at a time. See


PostrgreSQL also has a SQL-level cursor interface, if you need the 
additional operations. See the DECLARE CURSOR statement.


Posted on the users mailing list.