[sqlalchemy] Operational Error raised by except_

2011-01-12 Thread neurino
I have this model: ``I organize views with many view_options each one showing a sensor. A sensor can appear just once per view.`` sensors = Table('sensors', metadata, Column('id_cu', Integer, ForeignKey('ctrl_units.id'), primary_key=True, autoincrement=False),

[sqlalchemy] Re: Relationships : how to properly filter children ?

2011-01-12 Thread Franck
Dear all, I've been trying to answer my own question and use the attribute_mapped_collection component like this : mapper(Tournament, tournaments_table, properties={ subscriptions: relationship(Subscription, order_by=[desc(Subscription.status), Subscription.user_id],

[sqlalchemy] Re: Gracefully recovering from MySQL failures in a connection pool

2011-01-12 Thread cd...@peermore.com
On Dec 9 2010, 6:52 pm, Michael Bayer mike...@zzzcomputing.com wrote: Use the latest 0.6 release, MySQL reconnect detection had a bug up until 0.6.5. When a disconnect occurs, you need to suffer at least one exception throw.   When it occurs, the engine then disposes its pool of

[sqlalchemy] Return Custom Date objects instead of python inbuilt datetime.datetime objects

2011-01-12 Thread bool
Sql alchemy returns datetime.datetime objects upon querying a datetime column. We have our own custom datetime classes and I would like Sql alchemy to understand or return these custom datetime objects instead of datetime.datetime objects. I would also like sql alchemy to understand our custom

[sqlalchemy] SQLalchemy Date type creates Datetime column

2011-01-12 Thread bool
I am using sqlalchemy 0.5 with mssql server 2008. I see that when I want to create a 'Date' type column, sql alchemy creates a datetime column instead? Is this a bug in sql alchemy? -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this

Re: [sqlalchemy] Operational Error raised by except_

2011-01-12 Thread Michael Bayer
On Jan 12, 2011, at 7:28 AM, neurino wrote: I have this model: ``I organize views with many view_options each one showing a sensor. A sensor can appear just once per view.`` sensors = Table('sensors', metadata, Column('id_cu', Integer, ForeignKey('ctrl_units.id'), primary_key=True,

Re: [sqlalchemy] SQLalchemy Date type creates Datetime column

2011-01-12 Thread Michael Bayer
SQL server had no Date type previous to 2008.Upgrade to 0.6 where the behavior of Date/Datetime has been more carefully refined on SQL server to accurately detect the version of SQL server in use. On Jan 12, 2011, at 6:14 AM, bool wrote: I am using sqlalchemy 0.5 with mssql server 2008.

[sqlalchemy] Re: Operational Error raised by except_

2011-01-12 Thread neurino
I need always the same order_by in all app and it could be subject of modification and / or integration in the near future so which better place than mapper to define it once instead of any time I do a query? Anyway do you think there are alternate paths to get `all sensors but already choosen`

Re: [sqlalchemy] Re: Gracefully recovering from MySQL failures in a connection pool

2011-01-12 Thread Michael Bayer
On Jan 12, 2011, at 6:20 AM, cd...@peermore.com wrote: On Dec 9 2010, 6:52 pm, Michael Bayer mike...@zzzcomputing.com wrote: Use the latest 0.6 release, MySQL reconnect detection had a bug up until 0.6.5. When a disconnect occurs, you need to suffer at least one exception throw.

Re: [sqlalchemy] Return Custom Date objects instead of python inbuilt datetime.datetime objects

2011-01-12 Thread Michael Bayer
On Jan 12, 2011, at 6:24 AM, bool wrote: Sql alchemy returns datetime.datetime objects upon querying a datetime column. We have our own custom datetime classes and I would like Sql alchemy to understand or return these custom datetime objects instead of datetime.datetime objects. I would

Re: [sqlalchemy] Re: Relationships : how to properly filter children ?

2011-01-12 Thread Michael Bayer
On Jan 12, 2011, at 7:47 AM, Franck wrote: Dear all, I've been trying to answer my own question and use the attribute_mapped_collection component like this : mapper(Tournament, tournaments_table, properties={ subscriptions: relationship(Subscription,

[sqlalchemy] rollback not working

2011-01-12 Thread bool
: === [20110112 19:15:51:203 base.py:723 INFO] BEGIN INSERT INTO bbb (id, name, tt_start, tt_end, vt_start, vt_end) VALUES (?, ?, ?, ?, ?, ?) [20110112 19:15:51:205 base.py:945 INFO] INSERT INTO bbb (id, name, tt_start

[sqlalchemy] Re: rollback not working

2011-01-12 Thread bool
FYI I am using sqlserver 2008 and sqlalchemy 0.5 -- 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

Re: [sqlalchemy] Re: Relationships : how to properly filter children ?

2011-01-12 Thread Franck
Thank you very much ! I'm going to study the different options I have here. On Wed, Jan 12, 2011 at 3:01 PM, Michael Bayer mike...@zzzcomputing.comwrote: On Jan 12, 2011, at 7:47 AM, Franck wrote: Dear all, I've been trying to answer my own question and use the

Re: [sqlalchemy] rollback not working

2011-01-12 Thread Michael Bayer
') connection.execute(ins) trans.commit() except: trans.rollback() raise == OUTPUT: === [20110112 19:15:51:203 base.py:723 INFO] BEGIN INSERT INTO bbb (id, name, tt_start

[sqlalchemy] Re: Database Reflection - Forcing column names to be lowercase?

2011-01-12 Thread Harkirat
Thank you Michael ! On Jan 11, 5:25 pm, Michael Bayer mike...@zzzcomputing.com wrote: There's no straightforward way to do that.   Schemes to copy each Table to a new one with a lowercase .key attribute, using Inspector to generate the Table object programatically (basically means, implement

Re: [sqlalchemy] Re: Operational Error raised by except_

2011-01-12 Thread Michael Bayer
On Jan 12, 2011, at 8:46 AM, neurino wrote: I need always the same order_by in all app and it could be subject of modification and / or integration in the near future so which better place than mapper to define it once instead of any time I do a query? It sounds like the ordering here is for

[sqlalchemy] Re: Operational Error raised by except_

2011-01-12 Thread neurino
Well as I wrote ordering involves everything, also forms creation with formalchemy (make a select where all sensors are ordered that way etc) anyway I understand your point of view. quickest is a where sensor id not in (query), as a simple WHERE clause Problem comes when Sensor primary key is

Re: [sqlalchemy] Re: Operational Error raised by except_

2011-01-12 Thread Michael Bayer
On Jan 12, 2011, at 11:20 AM, neurino wrote: Well as I wrote ordering involves everything, also forms creation with formalchemy (make a select where all sensors are ordered that way etc) anyway I understand your point of view. quickest is a where sensor id not in (query), as a simple WHERE

[sqlalchemy] can't build c extensions for 0.6.6 on CentOS 5.5

2011-01-12 Thread Jon Nelson
I'm unable to build the C extensions for SQLAlchemy 0.6.6 on CentOS 5.5: gcc -pthread -fno-strict-aliasing -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fPIC -I/usr/include/python2.4 -c

[sqlalchemy] Unnecessary SQL emitted after a commit to get a PK?

2011-01-12 Thread Russell Warren
Check this code out: http://python.pastebin.com/kMV611z7 In there I generate an object instance, add it to a session, then commit it. I then try and access the id attribute (autoincrementing PK), which results in SQL being emitted... but the emitted SQL has the id value in it already! Is there

Re: [sqlalchemy] Unnecessary SQL emitted after a commit to get a PK?

2011-01-12 Thread Michael Bayer
Suppose a concurrent thread or process deleted your row in a new transaction and committed it, or didn't even commit yet hence locked the row, in between the time you said commit() and later attempted to access the attributes of the row. That's the rationale in a nutshell. see

[sqlalchemy] Mapper.get_property question

2011-01-12 Thread Eric Lemoine
Hi Mapper.get_property doesn't behave as I'd expect it to, so I'd just like to know if my understanding is incorrect. In the following testcase I'd expect the first test to pass and the second to fail, but I get the opposite. Thanks a lot. from sqlalchemy import Column, Integer, String from

[sqlalchemy] Reflection fails on binary columns in sqlite

2011-01-12 Thread scott
I'm trying to reflect a sqlite database with the hg tip, and it seems to fail whenever a BINARY column is present in the database. The same error happens whether reflecting the entire database at once (using metadata.reflect()) or just reflecting the specific table. A reduction with a traceback is

Re: [sqlalchemy] Mapper.get_property question

2011-01-12 Thread Michael Bayer
The name of the property from the mapper perspective is name. That's the contract of declarative: class MyClass(some_declarative_base): __tablename__ = 'j' x = Column(Integer, key='z') y = Column('p', Integer, key='w') == t = Table('j', metadata, Column('x', Integer,

Re: [sqlalchemy] Reflection fails on binary columns in sqlite

2011-01-12 Thread Michael Bayer
A fix for this specific issue is in re8edc49d0ad7. Note however that BINARY is not one of the type descriptors the SQLite dialect recognizes, so this reflects as NullType() on that backend (it always has). SQlite uses a value-based type system so it doesn't actually matter all that much.

[sqlalchemy] Re: Relationship (Foreign key) inside composite column

2011-01-12 Thread Arturo Sevilla
On Jan 10, 12:44 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Jan 10, 2011, at 2:21 PM, Arturo Sevilla wrote: Hello, Thanks again for the quick reply! I tried to isolate all the mapper columns to try to make it less confusing, now I know that was not a good idea.

Re: [sqlalchemy] Re: Relationship (Foreign key) inside composite column

2011-01-12 Thread Michael Bayer
On Jan 12, 2011, at 10:09 PM, Arturo Sevilla wrote: What I finally did is kind of black magic (not very proud of it) though it works for what I needed. Is kind of expanding the idea of the read-only property but making it writable by injecting what I called an updator which basically

[sqlalchemy] guard all session.query with try except?

2011-01-12 Thread can xiang
Hi, sqlalchemy is such a piece of great work. I'm very happy with it, while I indeed get a problem. I use sqlalchemy 0.6.6 in a non-threaded app. session is created at module level at once. autocommit is set to False. I see log shows: user = user_session.query(User).filter(User.hw_id