Python, Firefox programming and Irish Whiskey.

Thursday, September 2, 2010

SQLAlchemy Custom Types

SQLAlchemy is just ingenious. I must admit I haven't worked with any other ORM before, yet SQLAlchemy is more than that. I have been working with it's query language for years (4-5) and just recently I started to tuck into orm. So easy to use and so comprehensive.

If you want to do something related to your database, with SQLAlchemy you probably can. I, for example, need to "modify" a date-time value read from Oracle database backing our ERP. I suspect somebody didn't bother to set-up the timezone information properly. So all I had to do was to subclass types.TypeDecorator and override member function process_result_value to do some magic about my datetime values. That was it (I only read the data so I didn't care about converting back.)

No comments:

Post a Comment