nntpnews.net

Global Usenet Archiver


Register

[Haskell-cafe] programmatic DB interface?

Reply

  #11  
Old 04-02-10, 07:27 PM
Michael Snoyman
 
Posts: n/a
Default Re: [Haskell-cafe] Re: programmatic DB interface?

On Thu, Feb 4, 2010 at 7:38 PM, Colin Paul Adams
<colin@colina.demon.co.uk>wrote:

> >>>>> "Johannes" == Johannes Waldmann <waldmann@imn.htwk-leipzig.de>

> 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

_______________________________________________
Haskell-Cafe mailing list
Code:
Content visible to registered users only.
Code:
Content visible to registered users only.
Reply With Quote
  #12  
Old 05-02-10, 07:05 AM
Johannes Waldmann
 
Posts: n/a
Default Re: [Haskell-cafe] Re: programmatic DB interface?


> 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.




_______________________________________________
Haskell-Cafe mailing list
Code:
Content visible to registered users only.
Code:
Content visible to registered users only.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla -
Code:
Content visible to registered users only.
iEYEARECAAYFAktrwxUACgkQDqiTJ5Q4dm+iggCfcQFt+fqPd6 jq1kvCHQgWktut
50kAni/G/x1AvKjKcNQyyuZ+QYAagNID
=oWnD
-----END PGP SIGNATURE-----

Reply With Quote
  #13  
Old 05-02-10, 07:55 AM
Magnus Therning
 
Posts: n/a
Default Re: [Haskell-cafe] Re: programmatic DB interface?

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
Code:
Content visible to registered users only.
/M

--
Magnus Therning (OpenPGP: 0xAB4DFBA4)
magnusï¼*therning.org Jabber: magnusï¼*therning.org
Code:
Content visible to registered users only.
identi.ca|twitter: magthe


_______________________________________________
Haskell-Cafe mailing list
Code:
Content visible to registered users only.
Code:
Content visible to registered users only.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAktrzsYACgkQiMWTaatN+6Qo7QCfeYYiCve18U S2h4Ptpnkx+0zs
tIoAoIbRMhi0zrVM8LTJQf8Iebq61w7j
=4gU7
-----END PGP SIGNATURE-----

Reply With Quote
  #14  
Old 05-02-10, 10:57 AM
Johannes Waldmann
 
Posts: n/a
Default [Haskell-cafe] Re: programmatic DB interface?

> 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.


_______________________________________________
Haskell-Cafe mailing list
Code:
Content visible to registered users only.
Code:
Content visible to registered users only.
Reply With Quote
  #15  
Old 05-02-10, 01:02 PM
Michael Snoyman
 
Posts: n/a
Default Re: [Haskell-cafe] Re: programmatic DB interface?

On Fri, Feb 5, 2010 at 10:55 AM, Johannes Waldmann <
Code:
Content visible to registered users only.
> 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

_______________________________________________
Haskell-Cafe mailing list
Code:
Content visible to registered users only.
Code:
Content visible to registered users only.
Reply With Quote
  #16  
Old 05-02-10, 02:30 PM
Johannes Waldmann
 
Posts: n/a
Default [Haskell-cafe] Re: programmatic DB interface?

Michael Snoyman <michael <at> snoyman.com> writes:

> 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.


_______________________________________________
Haskell-Cafe mailing list
Code:
Content visible to registered users only.
Code:
Content visible to registered users only.
Reply With Quote
  #17  
Old 05-02-10, 02:35 PM
Colin Paul Adams
 
Posts: n/a
Default Re: [Haskell-cafe] Re: programmatic DB interface?

>>>>> "Johannes" == Johannes Waldmann <waldmann@imn.htwk-leipzig.de> writes:

Johannes> Michael Snoyman <michael <at> snoyman.com> writes:
>> Did you append an empty string in the SELECT statement?


Johannes> Magnus says 1. is wrong, but I don't see how the DB server
Johannes> could be convinced to send the ...T...Z format. In my
Johannes> application, the table definition contains 'timestamp
Johannes> without time zone' and I cannot change that.

That is exactly the problem - it is wrong for CalendarT.
--
Colin Adams
Preston Lancashire
_______________________________________________
Haskell-Cafe mailing list
Code:
Content visible to registered users only.
Code:
Content visible to registered users only.
Reply With Quote
  #18  
Old 05-02-10, 02:52 PM
Johannes Waldmann
 
Posts: n/a
Default Re: [Haskell-cafe] Re: programmatic DB interface?


> That is exactly the problem - it is wrong for CalendarT.


what do you mean by "it" ... what package should be fixed
(old-locale, haskelldb-hdbc-postgreqsl, ...)?
Because obviously something seems broken here.

J.



_______________________________________________
Haskell-Cafe mailing list
Code:
Content visible to registered users only.
Code:
Content visible to registered users only.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla -
Code:
Content visible to registered users only.
iEYEARECAAYFAktsMIsACgkQDqiTJ5Q4dm93RwCdHAXtJDysHA 2hR5JQLKlLk2wm
DDoAn0gcZ0seNtZ7OiYGZdCZ4hm1lMlo
=/APS
-----END PGP SIGNATURE-----

Reply With Quote
  #19  
Old 05-02-10, 03:10 PM
Colin Paul Adams
 
Posts: n/a
Default Re: [Haskell-cafe] Re: programmatic DB interface?

>>>>> "Johannes" == Johannes Waldmann <waldmann@imn.htwk-leipzig.de> 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
_______________________________________________
Haskell-Cafe mailing list
Code:
Content visible to registered users only.
Code:
Content visible to registered users only.
Reply With Quote
  #20  
Old 05-02-10, 03:17 PM
Johannes Waldmann
 
Posts: n/a
Default Re: [Haskell-cafe] Re: programmatic DB interface?

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.


_______________________________________________
Haskell-Cafe mailing list
Code:
Content visible to registered users only.
Code:
Content visible to registered users only.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla -
Code:
Content visible to registered users only.
iEYEARECAAYFAktsNocACgkQDqiTJ5Q4dm+JCwCeJuAAPLjLnr rX18CmhZpy86wE
ZgAAoMXy9/NPtLlCwFPwIpXfrd+EjHzO
=a0yd
-----END PGP SIGNATURE-----

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Haskell-cafe] PROPOSAL: Web application interface Michael Snoyman fa.haskell 9 24-01-10 11:30 PM
[Haskell-cafe] Web application interface Michael Snoyman fa.haskell 17 24-01-10 12:04 AM
[Haskell-cafe] HSGI: Haskell Server Gateway Interface Manlio Perillo fa.haskell 4 07-02-09 10:20 PM
[Haskell-cafe] Hackage web interface Hugo Pacheco fa.haskell 1 12-11-08 05:57 PM
Re: [Haskell-cafe] array fusion interface Henning Thielemann fa.haskell 1 05-08-08 12:56 PM


All times are GMT +1. The time now is 09:15 AM. Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0



For ads on this site use independent advertising companies. These companies may use some data (which does not include your name, address, email address or telephone number) about your visits to this and other websites to create advertisements on products and services you might enjoy. If you'd like more information and to know the options available to prevent the use of such information by these companies, click here

Abuse Ticket System