
Hello. What is currently the recommended higher level data base interface for Haskell? I want to construct queries in a programmatic/algebraic way, and I want typed queries and results. - I guess I want LINQ. The examples in http://book.realworldhaskell.org/read/using-databases.html seem to construct queries as strings. That's horrible! Looks exactly like PHP! Well, no, but it's a lower abstraction level than that I want to work at. I'm sure I'm just missing some package/framework here. Would takusen help? Where's its home page? this does not work: http://darcs.haskell.org/takusen/ Best, Johannes.

Hello Johannes, I think you are looking for HaskellDB, you can find it on hackage. I've been working with it myself and can absolutely recommend it. It is actively maintained by Justin Bailey. It's a EDSL for relational algebra which gets translated into SQL. It can use HDBC for instance as its *driver* to databases supported by HDBC. As with LINQ you need to put an initial effort into describing the tables and their columns of the database first, once that is done you can go ahead and express your queries in the EDSL, *typesafe* and higher-orderish too. HaskellDB was originally developed by Daan Leijen and Erik Meijer, two of the great old ones, both very well known here in the Haskell community. There are 2 papers describing the foundations of HaskellDB, google for Domain specific embedded compilers and The lambda calculus abroad (Chapter 5 of a rather large paper). both authored by Daan Leijen and Erik Meijer. HTH Günther Am 04.02.10 08:01, schrieb Johannes Waldmann:
Hello.
What is currently the recommended higher level data base interface for Haskell?
I want to construct queries in a programmatic/algebraic way, and I want typed queries and results. - I guess I want LINQ.
The examples in http://book.realworldhaskell.org/read/using-databases.html seem to construct queries as strings. That's horrible! Looks exactly like PHP!
Well, no, but it's a lower abstraction level than that I want to work at. I'm sure I'm just missing some package/framework here.
Would takusen help? Where's its home page? this does not work: http://darcs.haskell.org/takusen/
Best, Johannes.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

can use HDBC for instance as its *driver* to databases supported by HDBC.
ok, so I guess I need haskelldb-hdbc-postgresql but hdbc-postgresql has build failures http://hackage.haskell.org/package/HDBC-postgresql

Johannes Waldmann
ok, so I guess I need haskelldb-hdbc-postgresql but hdbc-postgresql has build failures http://hackage.haskell.org/package/HDBC-postgresql
Looks like HDBC-postgresql's Setup.hs needs to be updated to use newer versions of Cabal properly; if you're using the latest release of the Haskell Platform then I think it will build OK. -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com

anyone know what's happening here? I get this when executing a query via haskelldb-hdbc-postgresql-0.12 (The date is actually in the DB, so it's not a connection problem.) Convertible: error converting source data SqlString "2008-10-29 00:00:00" of type SqlValue to type Data.Time.LocalTime.LocalTime.LocalTime: Cannot parse using default format string "%Y-%m-%dT%T%Q"

"Johannes" == Johannes Waldmann
writes:
Johannes> anyone know what's happening here? I get this when Johannes> executing a query via haskelldb-hdbc-postgresql-0.12 (The Johannes> date is actually in the DB, so it's not a connection Johannes> problem.) Johannes> Convertible: error converting source data SqlString Johannes> "2008-10-29 00:00:00" of type SqlValue to type Johannes> Data.Time.LocalTime.LocalTime.LocalTime: Cannot parse Johannes> using default format string "%Y-%m-%dT%T%Q" I had this sort of problem. I sent a patch on the haskell-db list to use UTC - I believe the release behaviour is incorrect. You might check the list archives, as they have a better memory than I. -- Colin Adams Preston Lancashire

On Thu, Feb 4, 2010 at 7:38 PM, Colin Paul Adams
"Johannes" == Johannes Waldmann
writes: Johannes> anyone know what's happening here? I get this when Johannes> executing a query via haskelldb-hdbc-postgresql-0.12 (The Johannes> date is actually in the DB, so it's not a connection Johannes> problem.)
Johannes> Convertible: error converting source data SqlString Johannes> "2008-10-29 00:00:00" of type SqlValue to type Johannes> Data.Time.LocalTime.LocalTime.LocalTime: Cannot parse Johannes> using default format string "%Y-%m-%dT%T%Q"
I had this sort of problem. I sent a patch on the haskell-db list to use UTC - I believe the release behaviour is incorrect.
You might check the list archives, as they have a better memory than I.
I actually just came up against this as well in HDBC-postgresql. As a workaround, when I read a timestamp I concatenate with an empty string (||'') and then read with my own parse string:
"%Y-%m-%d %T%Q" This seems to work just fine. I'd like to debug it more, but I'm working on a short-deadline project. Hopefully when the month is out I'll be able to submit some patches for the problems I've run into. The other one that comes to mind off hand is I can't write to BYTEA fields either. Michael

Johannes> Data.Time.LocalTime.LocalTime.LocalTime: Cannot parse Johannes> using default format string "%Y-%m-%dT%T%Q"
this actually comes from the default format string that is defined in old-locale:System.Locale? iso8601DateFormat :: Maybe String -> String iso8601DateFormat mTimeFmt = "%Y-%m-%d" ++ case mTimeFmt of Nothing -> "" Just fmt -> 'T' : fmt and this can't be right - the 'T' is invalid? J.

On 05/02/10 07:04, Johannes Waldmann wrote:
Johannes> Data.Time.LocalTime.LocalTime.LocalTime: Cannot parse Johannes> using default format string "%Y-%m-%dT%T%Q"
this actually comes from the default format string that is defined in old-locale:System.Locale?
iso8601DateFormat :: Maybe String -> String iso8601DateFormat mTimeFmt = "%Y-%m-%d" ++ case mTimeFmt of Nothing -> "" Just fmt -> 'T' : fmt
and this can't be right - the 'T' is invalid?
It's very much valid, see http://en.wikipedia.org/wiki/ISO_8601 /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus@therning.org Jabber: magnus@therning.org http://therning.org/magnus identi.ca|twitter: magthe

and then read with my own parse string:"%Y-%m-%d %T%Q" This seems to work just fine.
Thanks. - When I'm using that format string, I get: Convertible: error converting source data SqlLocalTime 2008-10-29 00:00:00 of type SqlValue to type Data.Time.LocalTime.LocalTime.ZonedTime: incompatible types I guess I need to find out who wants ZonedTime. In my DB description (generated by dbdirect), the only time-related type is CalendarTime. J.

On Fri, Feb 5, 2010 at 10:55 AM, Johannes Waldmann < waldmann@imn.htwk-leipzig.de> wrote:
and then read with my own parse string:"%Y-%m-%d %T%Q" This seems to work just fine.
Thanks. - When I'm using that format string, I get:
Convertible: error converting source data SqlLocalTime 2008-10-29 00:00:00 of type SqlValue to type Data.Time.LocalTime.LocalTime.ZonedTime: incompatible types
I guess I need to find out who wants ZonedTime.
In my DB description (generated by dbdirect), the only time-related type is CalendarTime.
J.
Did you append an empty string in the SELECT statement? If you append the empty string (||''), HDBC treats the field as text and so returns a SqlByteString. However, if you do not append the empty string, it treats the field as a timestamp and tries to convert it before it even reaches your code.
All of this is just speculation, of course, since I haven't actually looked at the code. But my "extensive" (ie, 5 minute) testing implies it to be true. Michael

Michael Snoyman
Did you append an empty string in the SELECT statement?
I did not write a SELECT statement (see first post of this thread) ... SELECTs are generated by haskelldb(-hdbc-postgresql) I have a working version now, but only by 1. changing the format string computation to "%Y-%m-%d" ++ ' ' : fmt 2. adding a line in instance Convertible SqlValue ZonedTime for safeConvert y@(SqlLocalTime x) Magnus says 1. is wrong, but I don't see how the DB server could be convinced to send the ...T...Z format. In my application, the table definition contains 'timestamp without time zone' and I cannot change that. J.

"Johannes" == Johannes Waldmann
writes:
Johannes> Michael Snoyman

"Johannes" == Johannes Waldmann
writes:
>> That is exactly the problem - it is wrong for CalendarT. Johannes> what do you mean by "it" ... what package should be fixed Johannes> (old-locale, haskelldb-hdbc-postgreqsl, ...)? Because Johannes> obviously something seems broken here. "It" is the use of unzoned times. I sent the following patch to the haskelldb list several months ago. But there has not been a new release since then. Colin> It is just the code to generate the SQL for CREATE TABLE is Colin> presumably faulty. For CalendarTimeT columns it should Colin> generate a time of Colin> timestamp with time zone Colin> as CalendarTime is a zoned timestamp. here's my patch: --- Default.hs~ 2009-02-13 23:06:25.000000000 +0000 +++ Default.hs 2009-10-01 16:43:34.000000000 +0100 @@ -92,7 +92,7 @@ IntegerT -> SqlType "bigint" DoubleT -> SqlType "double precision" BoolT -> SqlType "bit" - CalendarTimeT -> SqlType "timestamp" + CalendarTimeT -> SqlType "timestamp with time zone" BStrT a -> SqlType1 "varchar" a -- Colin Adams Preston Lancashire

Colin Paul Adams wrote:
Colin> It is just the code to generate the SQL for CREATE TABLE is Colin> presumably faulty.
well this wouldn't help in my case since I did not CREATE TABLE from haskelldb. In my application, the DB is given externally, and I used Database.HaskellDB.DBDirect to create the Haskell interface. J.

On Thu, Feb 04, 2010 at 09:26:43AM +0100, Günther Schmidt wrote:
I think you are looking for HaskellDB, you can find it on hackage. I've been working with it myself and can absolutely recommend it.
It is actively maintained by Justin Bailey.
It's been some time since I last tried HaskellDB but it used to generate SQL queries that no SGBD could ever optimize :D. Do you have better experiencies in the performance camp? Thanks, -- Felipe.

What is currently the recommended higher level data base interface for Haskell?
I want to construct queries in a programmatic/algebraic way,
Would takusen help? Where's its home page? this does not work: http://darcs.haskell.org/takusen/
Takusen still requires you to supply queries as strings, so no, it wouldn't help. BTW, it has moved to http://code.haskell.org/takusen The only game in town is HaskellDB, AFAIK. Alistair
participants (8)
-
Alistair Bayley
-
Colin Paul Adams
-
Felipe Lessa
-
Günther Schmidt
-
Ivan Lazar Miljenovic
-
Johannes Waldmann
-
Magnus Therning
-
Michael Snoyman