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:svilen (sdob@sistechnology.com)
Date:08/30/2007 05:41:16 AM
List:com.googlegroups.sqlalchemy

IMO current way as of src (sorry i havent read docs at user level), u'll need two-side implementaion - one abstract SA, and one dialect-dependent. In each dialect, there are 2 mappings: one abstractSAtype->specificDialectType (look for something named colspecs), and another one used for reflection - named 'pragmanames' or ischemanames' or 'similar.

so u have to create your custom abstract type and a custom dialect type(s) and add them to those mappings - eventualy substituting with some available type where inapplicable.

see in some dialect (in database/*) how a dialect-specific type is made, subclassing the abstract one.

of course there might be easier "official" way...

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...