Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Christoph Bauer <ich <at> christoph-bauer.net>
Subject: ANN: hesql
Newsgroups: gmane.comp.lang.haskell.cafe
Date: Thursday 12th November 2009 20:58:23 UTC (over 7 years ago)
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
 
CD: 3ms