[database-devel] postgresql-simple - how hard would it be to do the same for sqlite?

Leon Smith leon.p.smith at gmail.com
Wed Aug 1 21:29:13 CEST 2012

To clarify what I meant by a low-level binding:

On Tue, Jul 31, 2012 at 5:25 PM, Janne Hellsten <jjhellst at gmail.com> wrote:

> Put into SQLite API context, here's how a typical SELECT might work,
> using some sort of pseudo-C to make it easier to read
> conn = sqlite3_open("...");
> // create a prepared statement:
> stmt = sqlite3_prepare(conn, "SELECT * from test_table");
> // process all rows in the result
> while (sqlite3_step(stmt) != SQLITE_DONE)
> {
>     // access the current row
>     char* colValue = sqlite3_column_text(stmt, columnNdx);
>     // there are separate column accessors for different types, like
> sqlite_column_blob, text, etc.
> }
> sqlite3_finalize(stmt);
> sqlite3_close(conn);

Basically, the aim of the low level binding is to create this sort of
pseudo-C in Haskell,  though it would be preferable to not have to
explicitly finalize the statement.   (Though I did end up adding
unsafeFreeResult to postgresql-libpq to explicitly trigger the finalizer
that calls PQclear,  for better or worse.    I did so at the request of
Felipe Lessa  for use in persistent-postgresql.)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/database-devel/attachments/20120801/2bc66668/attachment.htm>

More information about the database-devel mailing list