On 1/18/06, Nicholas Wieland <[EMAIL PROTECTED]> wrote:
> On 1/18/06, Michael Bayer <[EMAIL PROTECTED]> wrote:
> >
> > I assume youre using SQLite ? the other database adapters use datetime
> > objects and date/time columns in the database, so string representations
> > shouldnt matter.
>
> Sorry, I forgot to say I'm using Postgresql 8.
> Maybe the problem is my test:
>
> def testRecord (self):
> t = reflect.mapTable (self.engine, 'test')
> r = reflect.getRecord (t, id = 1)
> self.assertEqual (
> [r.id, r.name, '%s' % r.date], [1, 'Nicholas', '1978-10-12
> 00:00:00,00'])
>
> Anyway, I'll try to use datetime objects directly.
Now my tests pass, but I have another problem with client encoding: in
my application I need to convert from mx.DateTime.DateTime to string,
then back again to mx.DateTime.DateTime using
mx.DateTime.Parser.DateTimeFromString, that AFAIK should return a
locale/encoding generic object.
For some reason this just don't work, and psycopg raises a ProgrammingError
psycopg.ProgrammingError: ERROR: invalid input syntax for type
timestamp: "1978-10-11 00:00:0,000000"
UPDATE test SET name='Nicholas', date='1978-10-11 00:00:0,000000'
WHERE test.id = '1'
Annoying, to say the least ... :)
The incriminated code is:
if isinstance (column.type, types.DateTime):
mxdt = DateTimeFromString (self.w [k].props.text)
setattr (self.record, column.name, mxdt)
else:
setattr (self.record, column.name, self.w [k].props.text)
objectstore.commit ()
The format psycopg expects is '1978-10-11 00:00:0.000000' (as always,
. insted of ,)
The thing that pisses me off is that I don't pass a generic "string"
to commit (), but a normal mx.DateTime :(
Suggestions ? I've tried quite everything, but I'm no expert ...
TIA,
ngw
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users