On Tuesday, May 31, 2011 05:42:26 pm Michael Bayer wrote:
> >> This is a malformed date value.   SQLite has no date type so SQLA must
> >> parse it.  It assumes its only parsing strings that it created.  If
> >> you're artificially generating strings to be used with DateTime, make
> >> sure you
> >>
> >> put dates in the format as follows:
> >> 
> >>
> >> 2011-03-15 12:05:57.10558
> >
> > 
> >
> > I have run across this problem multiple times and it scares me with
> > regards to  going into production with my application.  There seems to
> > be no clean way with-in sqlachemy to recover from this data
> > corruption.  Once you get a malformed date in your table, all your
> > sqlalchemy reads will fail.
> 
> This is limited entirely to the usage of the DateTime type with SQLite,
> which does not have any native date types.

Well, to be pedantic, not quite -- it also happens with Date and probably with 
Time too.  (I don't use DateTime at all).

> If your database's data
> wasn't generated using this type, then either don't use it (use String
> instead), or use a custom type that performs the date parsing logic of
> your choice - an appropriate scheme would use TypeDecorator around
> String.    Some examples of TypeDecorator are at
> http://www.sqlalchemy.org/docs/core/types.html#typedecorator-recipes .

That sounds fairly sensible, I might do so if I get bit by this again.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to