Christoph Bauer | 12 Nov 21:58

ANN: hesql

Hello,

sure, your program could use a database with HDBC. But I'll guess
(since you love static typing so much) you dislike formulating queries
in strings and to check the positions of your ?-placeholders and to
convert your values with fromSql/toSql. Maybe you would prefer
for your select query a list of tuples instead of a list of lists,
because your beloved pattern matching needs always a dummy case.

And here [1] is hesql... it's a preprocessor, which rewrites SQL-Queries
as haskell functions. You put all your SQL-Queries
  (for example

   verifyLogin login' password' =
      select1' Accountid, Login, RealName, Email from Account
        where (password is null or password  = md5(password')) and Lower(Login) = login'
             and not Locked;
    )
in a module (example/Account.hesql) and run

  $ hesql example/Account.hesql dbname=example

which will write example/Account.hs, the real haskell module.

It will generate code for a haskell function with the type:

verifyLogin :: Stmts -> String -> String 
    ->  IO (Maybe (Int, String, String, String))

(Ok, this is not quite correct. Check the README.)

And Of course my SQL-Parser is very incomplete. Hesql works only with
postgresql, etc, etc. So, please send me patches :-) Don't expect too much.

Christoph Bauer

[1] on hackageDB
Colin Paul Adams | 13 Nov 08:00
Picon
Picon
Favicon

Re: ANN: hesql


>>>>> "Christoph" == Christoph Bauer <ich <at> christoph-bauer.net> writes:
Christoph> Hello, sure, your program could use a database with Christoph> HDBC. But I'll guess (since you love static typing so Christoph> much) you dislike formulating queries in strings and to Christoph> check the positions of your ?-placeholders and to Christoph> convert your values with fromSql/toSql. You guess right. That's why I use HaskellDB. Why would hesql be an improvement for me? It sounds like several steps backwards? -- -- Colin Adams Preston Lancashire
Jake Wheat | 14 Nov 20:37

Re: ANN: hesql

Hello Christoph,

I've been working on a SQL parser
(http://hackage.haskell.org/package/hssqlppp) which might be useful
for your project, although it might be a bit heavy weight (its feature
scope getting more and more out of control...). Adding support for
parsing ? placeholder statements is on my todo list, I could bump it
up to the top if that would be useful to you.

Also, have you checked out MetaHDBC
(http://www.haskell.org/haskellwiki/MetaHDBC). I think it has similar
goals to your project.

2009/11/13 Colin Paul Adams <colin <at> colina.demon.co.uk>:

> Why would hesql be an improvement for me? It sounds like several steps backwards?
The last few paragraphs on this page http://lindstroem.wordpress.com/2008/09/18/metahdbc-paper-draft/ (comment dated November 4, 2008 at 9:31 pm, starting with 'Second, MetaHDBC is a thin layer above a DBMS, as compared to ...') give some reasons why an approach like this might sometimes be preferred to a haskelldb-like approach, different situations can recommend one or the other. Thanks, Jake Wheat

Gmane