Re: Roundtrip SQL data especially datetime

2006-12-18 Thread John Nagle
GHUM wrote: >>One side effect of this being third party code is that hosting >>services may not have it available, even when they have both Python >>and MySQL up. This is never a problem with Perl or PHP, so that's >>a negative for Python. > > > I for one think it is a good thing to not have

Re: Roundtrip SQL data especially datetime

2006-12-18 Thread GHUM
> One side effect of this being third party code is that hosting > services may not have it available, even when they have both Python > and MySQL up. This is never a problem with Perl or PHP, so that's > a negative for Python. I for one think it is a good thing to not have MySQL adapters int

Re: Roundtrip SQL data especially datetime

2006-12-17 Thread John Machin
dyork wrote: > "Carsten Haese" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > This may come as a shock to you, but MySQL is not the only database > > engine on the planet. Your recommendation may apply to MySQL, but it is > > not true for all databases in general. I can name at

Re: Roundtrip SQL data especially datetime

2006-12-17 Thread fumanchu
dyork wrote: > "Dennis Lee Bieber" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > > If you actually look at what the various DB-API adapters produce > > when sending to the database engine, floats, bools, etc. are all sent as > > string representations; about the only source for

Re: Roundtrip SQL data especially datetime

2006-12-17 Thread Diez B. Roggisch
> > The advantage of static typing in this context is that the variable still > holds the type even if the value happens to be null. Any value that has been > exposed to user input comes back as a string and has to be validated and > converted to the correct data type. Static typing provides a

Re: Roundtrip SQL data especially datetime

2006-12-17 Thread dyork
"Fredrik Lundh" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > if you think that Python isn't typed, you've completely missed how things > work. your problem is that you're removing every trace of the type > information by casting everything to strings, not that Python itself (n

Re: Roundtrip SQL data especially datetime

2006-12-17 Thread dyork
"John Nagle" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >Actually, MySQLdb isn't released for Python 2.5 yet, so for > anything with a database, you need an older version of Python. It's not really a problem so far. >If you really want to change the conversions for TIMES

Re: Roundtrip SQL data especially datetime

2006-12-17 Thread dyork
"Dennis Lee Bieber" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > If you actually look at what the various DB-API adapters produce > when sending to the database engine, floats, bools, etc. are all sent as > string representations; about the only source for problems would be > in

Re: Roundtrip SQL data especially datetime

2006-12-17 Thread dyork
"Carsten Haese" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > This may come as a shock to you, but MySQL is not the only database > engine on the planet. Your recommendation may apply to MySQL, but it is > not true for all databases in general. I can name at least two examples > (I

Re: Roundtrip SQL data especially datetime

2006-12-17 Thread dyork
"Carsten Haese" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Python is a typed language, too, and "this thing" works just fine, > provided that you are using a reasonable DB-API implementation, and > provided that you're actually binding objects as parameters instead of > just st

Re: Roundtrip SQL data especially datetime

2006-12-17 Thread dyork
"fumanchu" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Here's the web adaptation layer I use: > http://projects.amor.org/misc/browser/alamode.py > Have a look at the coerce_in and coerce_out functions. Thanks! Plenty of useful ideas there. My web framework already does all the

Re: Roundtrip SQL data especially datetime

2006-12-17 Thread Hertha Steck
Am Sat, 16 Dec 2006 16:31:18 -0500 schrieb Carsten Haese: > > This may come as a shock to you, but MySQL is not the only database > engine on the planet. Your recommendation may apply to MySQL, but it is > not true for all databases in general. I can name at least two examples > (Informix and Ora

Re: Roundtrip SQL data especially datetime

2006-12-17 Thread Fredrik Lundh
dyork wrote: > Most values tend to work, but only because the SQL string representation > happens to be the same as the Python representation. That may not apply to > some float values, bool, perhaps others. I had hoped the tools would have > solved those problems so I don't have to. In typed l

Re: Roundtrip SQL data especially datetime

2006-12-17 Thread Diez B. Roggisch
> > Most values tend to work, but only because the SQL string representation > happens to be the same as the Python representation. That may not apply to > some float values, bool, perhaps others. I had hoped the tools would have > solved those problems so I don't have to. In typed languages (J

Re: Roundtrip SQL data especially datetime

2006-12-16 Thread John Machin
Carsten Haese wrote: > On Sat, 2006-12-16 at 20:48 +, John Nagle wrote: > > The SourceForge page > > > >http://sourceforge.net/project/showfiles.php?group_id=22307 > > > > says > > > > "MySQL versions 3.23-5.0; and Python versions 2.3-2.4 are supported." > > > > Last release was A

Re: Roundtrip SQL data especially datetime

2006-12-16 Thread Carsten Haese
On Sat, 2006-12-16 at 20:48 +, John Nagle wrote: > The SourceForge page > >http://sourceforge.net/project/showfiles.php?group_id=22307 > > says > > "MySQL versions 3.23-5.0; and Python versions 2.3-2.4 are supported." > > Last release was April, 2006. There's no binary for Pyt

Re: Roundtrip SQL data especially datetime

2006-12-16 Thread John Nagle
Marc 'BlackJack' Rintsch wrote: > In <[EMAIL PROTECTED]>, John Nagle wrote: > >>John Machin wrote: >> >>>John Nagle wrote: >>> dyork wrote: >"John Machin" <[EMAIL PROTECTED]> wrote in message >news:[EMAIL PROTECTED] > > > >>If you have, as you should, Python 2.5, y

Re: Roundtrip SQL data especially datetime

2006-12-16 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, John Nagle wrote: > John Machin wrote: >> John Nagle wrote: >>>dyork wrote: "John Machin" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >If you have, as you should, Python 2.5, you can use this: >>> >>>Actually, MySQLdb isn't released

Re: Roundtrip SQL data especially datetime

2006-12-16 Thread John Nagle
John Machin wrote: > John Nagle wrote: > >>dyork wrote: >> >>>"John Machin" <[EMAIL PROTECTED]> wrote in message >>>news:[EMAIL PROTECTED] >>> >>> If you have, as you should, Python 2.5, you can use this: >> >>Actually, MySQLdb isn't released for Python 2.5 yet > > > Actually, that's int

Re: Roundtrip SQL data especially datetime

2006-12-16 Thread fumanchu
dyork wrote: > Thanks Gabriel, but when I said "round trip" I really did mean: convert all > the way to string and all the way back again, so your kind advice is not all > that helpful. I need string to get to a non-Python object or a Web page. Then you need two adaptation layers: one between your

Re: Roundtrip SQL data especially datetime

2006-12-16 Thread John Machin
John Nagle wrote: > dyork wrote: > > "John Machin" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > >>If you have, as you should, Python 2.5, you can use this: > > Actually, MySQLdb isn't released for Python 2.5 yet Actually, that's interesting information [why should it

Re: Roundtrip SQL data especially datetime

2006-12-15 Thread Leo Kislov
John Nagle wrote: > Routinely converting MySQL DATETIME objects to Python "datetime" > objects isn't really appropriate, because the MySQL objects have a > year range from 1000 to , while Python only has the UNIX range > of 1970 to 2038. You're mistaken. Python datetime module excepts year

Re: Roundtrip SQL data especially datetime

2006-12-15 Thread John Nagle
dyork wrote: > "John Machin" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > I was looking for a constructor that was the complement of str(). Most/many > languages would provide that. Sometimes it's called parse(). > > >>The constructor is datetime.datetime(year, ., second)

Re: Roundtrip SQL data especially datetime

2006-12-15 Thread Frank Millman
dyork wrote: > When getting data from a database using the dbapi and an SQL query, how do > you in general round trip the data? Especially date-time? > This is what I do. I am posting this partly because I hope it helps, partly because it is a bit clunky and I would appreciate suggestions for imp

Re: Roundtrip SQL data especially datetime

2006-12-15 Thread Carsten Haese
On Sat, 2006-12-16 at 04:27 +, dyork wrote: > "John Machin" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > I suppose it all depends on your definition of obvious :-) > I was looking for a constructor that was the complement of str(). Most/many > languages would provide that

Re: Roundtrip SQL data especially datetime

2006-12-15 Thread dyork
"John Machin" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I suppose it all depends on your definition of obvious :-) I was looking for a constructor that was the complement of str(). Most/many languages would provide that. Sometimes it's called parse(). > The constructor is da

Re: Roundtrip SQL data especially datetime

2006-12-15 Thread dyork
Thanks Gabriel, but when I said "round trip" I really did mean: convert all the way to string and all the way back again, so your kind advice is not all that helpful. I need string to get to a non-Python object or a Web page. DY "Gabriel Genellina" <[EMAIL PROTECTED]> wrote in message news:[EM

Re: Roundtrip SQL data especially datetime

2006-12-15 Thread John Machin
dyork wrote: > When getting data from a database using the dbapi and an SQL query, how do > you in general round trip the data? Especially date-time? > > An SQL datetime column translates nicely into a Python datetime (surprise), > which then translates into a string like '2005-08-03 07:32:48'. It

Re: Roundtrip SQL data especially datetime

2006-12-15 Thread Gabriel Genellina
On 15 dic, 07:44, "dyork" wrote: > When getting data from a database using the dbapi and an SQL query, how do > you in general round trip the data? Especially date-time? > > An SQL datetime column translates nicely into a Python datetime (surprise), > which then translates into a string like '2005