[sqlalchemy] Re: Mapping an object to multiple tables

2010-01-18 Thread bojanb
This can be done and it's not too complicated, but beware as in 95% of the time it's a deficency in your model; ie. you can refactor your model so that you don't need this. If it's the other 5% of cases, here's what the code looks like (I can't honestly remember if I read this in the docs or got

[sqlalchemy] Re: Column property vs. Python (class) property for calculated columns

2010-01-18 Thread bojanb
However, I have issues with the difference in NULL value semantics between Python and SQL. Ie. if a calculated column is defined via a column_property as price*amount, then the result will be NULL if any of the values is NULL. However, in Python, None*something throws a TypeError, so the

[sqlalchemy] how to get data type that InstrumentedAttribute expects

2010-01-18 Thread Kent
Given an InstrumentedAttribute object, how can you determine which data type (int, str, datetime, etc) that the attribute expects to house? Thanks in advance if anyone can answer this. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this

Re: [sqlalchemy] how to get data type that InstrumentedAttribute expects

2010-01-18 Thread Michael Bayer
On Jan 18, 2010, at 7:33 AM, Kent wrote: Given an InstrumentedAttribute object, how can you determine which data type (int, str, datetime, etc) that the attribute expects to house? Thanks in advance if anyone can answer this. for a column-based attribute you can get at the column and its

[sqlalchemy] Re: Column property vs. Python (class) property for calculated columns

2010-01-18 Thread avdd
Here's my reworking of the example for time types: from datetime import datetime, timedelta, date from sqlalchemy import MetaData, Table, Column, DateTime, Date, Interval from sqlalchemy.orm import mapper, create_session metadata = MetaData('postgresql:///avdd') interval_table1 =

[sqlalchemy] Re: how to get data type that InstrumentedAttribute expects

2010-01-18 Thread Kent
Thank you. On Jan 18, 9:41 am, Michael Bayer mike...@zzzcomputing.com wrote: On Jan 18, 2010, at 7:33 AM, Kent wrote: Given an InstrumentedAttribute object, how can you determine which data type (int, str, datetime, etc) that the attribute expects to house? Thanks in advance if anyone

[sqlalchemy] Doubt about UnicodeText

2010-01-18 Thread Tomas Zulberti
Hi. I have the following error while making a query using the models: raise exc.DBAPIError.instance(statement, parameters, e, connection_invalidated=is_disconnect) ProgrammingError: (ProgrammingError) can't adapt 'UPDATE data_items SET content=%(content)s WHERE data_items.serial_id =

[sqlalchemy] Re: Name clash in SqlSoup

2010-01-18 Thread PauloS
On Jan 16, 4:06 pm, Michael Bayer mike...@zzzcomputing.com wrote: OK SQLSoup is using the Session.extension which adds a .query attribute unconditionally.   this bug is fixed in trunk.   I can't do it in 0.5 since .query is a public API that people might be relying upon.   To work around in

Re: [sqlalchemy] Re: Name clash in SqlSoup

2010-01-18 Thread Michael Bayer
On Jan 18, 2010, at 3:35 PM, PauloS wrote: On Jan 16, 4:06 pm, Michael Bayer mike...@zzzcomputing.com wrote: OK SQLSoup is using the Session.extension which adds a .query attribute unconditionally. this bug is fixed in trunk. I can't do it in 0.5 since .query is a public API that

[sqlalchemy] Mixed inheritance mapping and multiple binds

2010-01-18 Thread Ross Vandegrift
Hello, I've run into a case where my code works with a single engine binding but breaks if bound to multiple engines. I'm doing some things that might be considered weird - mixing joined and single table inheritance to reduce data storage, inheriting mappers from other derived mappers. The

Re: [sqlalchemy] Mixed inheritance mapping and multiple binds

2010-01-18 Thread Michael Bayer
On Jan 18, 2010, at 6:27 PM, Ross Vandegrift wrote: Shouldn't this work on SA 0.5.8? engine = create_engine('sqlite:///:memory:', echo=True) metadata.create_all(engine) binds = { device_table : engine, switch_table : engine } Currently its looking at the mapped table of