chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] DBI


From: Alaric Snell-Pym
Subject: Re: [Chicken-users] DBI
Date: Thu, 28 Feb 2008 11:50:33 +0000



dbi:query-fold, dbi:query-map, query-for-each.  I thought about
implementing these, but I
        haven't been able to think of the use case that makes them
necessary in the presence
        Scheme's fold, map, and for-each, other than as shorthand (which
could be define'd
        in place in a heartbeat for anyone who wants it)

Result streaming. You want to avoid having a query function that
returns a list of rows, where possible, because some DB APIs will let
you stream rows from the server as you consume them.

For a million row result, being able to stream them from the server
into a function that converts them to HTML and streams them out to a
browser, or whatever, is a big save in server memory :-)

Ideally, have your query function return a proper *stream* of conses
with promises in, then use existing stream fold/map/filter on them,
of course. Vague memory there's an SRFI for that, but I've never had
the need to look it up in detail.

dbi:insert-id  Should this come from a function, or should it be
returned as a response to
        dbi:query?  I wouldn't mind seeing the query handler be smart
enough that if my query
        involves INSERT and i've inserted a row that becomes ID 42, that
the response would
        be something like '((rows-affected 1) (insert-id 42)) Certainly,
we'd want to look at what
        we'd want to normalize these labels to, but that's not a huge issue.

        The related question is whether singleton response values (like
rows-affected with
        nothing else) should return as a singleton (a)list or as a numeric
value --> My vote would
        be to return the singleton (a)list  to simplify the conditional
checking the caller needs
        to use.

In my past I've preferred to have "query" procedures for SQL queries,
and "execute" procedures for INSERT et al, which don't return a
table, just success/failure. Then you can have a more specific
procedure for "insert" that returns inserted ID metadata.

ABS

--
Alaric Snell-Pym
Work: http://www.snell-systems.co.uk/
Play: http://www.snell-pym.org.uk/alaric/
Blog: http://www.snell-pym.org.uk/?author=4






reply via email to

[Prev in Thread] Current Thread [Next in Thread]