On Sep 24, 7:09 pm, Michael Bayer <mike...@zzzcomputing.com> wrote:
> If you have a stringified date format that you'd like to pass to SQL 
> statements as values, such that the string is parsed into a datetime then 
> passed to the DBAPI, just use TypeDecorator around 
> DateTime:http://www.sqlalchemy.org/docs/core/types.html?highlight=typedecorato...

Yeah, but I can't make reflection use the TypeDecorator subclass
instead of DATETIME can I?  I can think of two options:

 1.  Go through each reflected table and replace each DATETIME type
with a TypeDecorator subclass.
 2.  Find all of the DATETIME columns, and implement a preprocessing
step for all of them.  So whenever I encounter a DATETIME value, I'd
convert it from a string into a Python datetime before passing it into
insert/update.

I don't necessarily like either of these options as I was hoping to
not have my code have to deal with these kinds of typing issues, but I
might be out of luck.

One other idea though:  is there any way to use the compiler extension
to do this?  For instance, could I add a @compiles function that
basically says "if this is a datetime column then do this else do
whatever is done by default for columns"?  The type compilation
capability almost does what I want, except it's for DDL rather than
DML.

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

Reply via email to