3 messages in com.googlegroups.sqlalchemy[sqlalchemy] Re: How to construct a d...
FromSent OnAttachments
marq30 Aug 2007 05:20 
svilen30 Aug 2007 05:41 
Michael Bayer30 Aug 2007 08:14 
Subject:[sqlalchemy] Re: How to construct a dialect-aware user type
From:Michael Bayer (mike@zzzcomputing.com)
Date:08/30/2007 08:14:30 AM
List:com.googlegroups.sqlalchemy

On Aug 30, 2007, at 8:20 AM, marq wrote:

Hello,

apologies if I'm the obvious or important things in the documentation - and I'm obviously very new to SQLAlchemy...

I'd like to create my own types which are aware of different database dialects. For example, I need a type 'Double' which holds a representation of a double precision floating point number. With MySQL, I would robably use the native DOUBLE type, with Oracle BINARY_DOUBLE. I would like to encapsulate the data base dependency with a properly defined custom type.

Is there a straigtforward way to achieve this? I have managed to build custom types, of course, but I haven't found a way on how to deduce the current data base engine / dialect from the types.TypeEngine...

we have one "user defined" type thats doing something like this right now, the Interval type in types.py. You might take a look at that for ideas - it uses "DateTime" for most dialects except for Postgres where it uses "Interval".