Re: [sqlalchemy] Unit testing, mocking and dependency injection with SA Declarative.

2013-09-12 Thread James C
Regarding the Postgres in production and SQLite in testing differences, we've previously had problems with Postgres's Array - which doesn't exist in SQLite. Also watch out for the differences between how they interpret GROUP BY and DISTINCT - I've had this problem only today where a

Re: [sqlalchemy] Mutable column_properties

2013-09-12 Thread Philip Scott
Thanks Michael a column_property() against a SQL expression by definition is not writable. Your table doesn't have a CAST trigger inside of it for when an int is written to it that would convert it back to a string. in this case since data is already loaded fully as a single column you

Re: [sqlalchemy] dynamic schema with postgresql

2013-09-12 Thread Michael Bayer
On Sep 11, 2013, at 10:36 PM, Joe Martin jandos...@gmail.com wrote: Thank you for your reply. Then I thought the following would work: company_schema = 'c' + str(company_id) db.session.execute(CreateSchema(company_schema)) db.session.commit()

Re: [sqlalchemy] Mutable column_properties

2013-09-12 Thread Jonathan Vanasco
I just spend 30mins with pdb; I was wrong ; I think it would be way too hard to get it into the ORM. The way MutableDict seems to be currently integrated, the entire value is updated for the key , and the original value seems to be obliterated. Outside of the ORM -- do you have any references

Re: [sqlalchemy] Mutable column_properties

2013-09-12 Thread Michael Bayer
On Sep 12, 2013, at 2:35 PM, Jonathan Vanasco jonat...@findmeon.com wrote: I just spend 30mins with pdb; I was wrong ; I think it would be way too hard to get it into the ORM. The way MutableDict seems to be currently integrated, the entire value is updated for the key , and the original

Re: [sqlalchemy] Mutable column_properties

2013-09-12 Thread Michael Bayer
On Sep 12, 2013, at 12:02 PM, Philip Scott safetyfirstp...@gmail.com wrote: Thanks Michael a column_property() against a SQL expression by definition is not writable. Your table doesn't have a CAST trigger inside of it for when an int is written to it that would convert it back to a

[sqlalchemy] Re: Mutable column_properties

2013-09-12 Thread Jonathan Vanasco
I might be interpreting all this wrong, but I don't think the column_property needs to be writable. I think the situation is this: Under Postgres, with HSTORE it's possible to INSERT/UPDATE/DELETE only certain values from within the store. Under SqlAlchemy, the entire object is

[sqlalchemy] Re: Mutable column_properties

2013-09-12 Thread Jonathan Vanasco
Actually, this is more correct for multi-key updates: -- select before update SELECT id, kv-'x' AS kv_x , kv-'y' AS kv_y , kv-'z' AS kv_z FROM test_class ; -- update 2 columns ; these 3 are identical kvkv UPDATE test_class SET kv = kv || hstore(ARRAY['z','zz','x','xx']);

Re: [sqlalchemy] Mutable column_properties

2013-09-12 Thread Michael Bayer
the update() and insert() constructs support this but this usage isn't integrated in the ORM (and would seem like a pretty low priority feature in any case). On Sep 12, 2013, at 1:45 PM, Jonathan Vanasco jonat...@findmeon.com wrote: Actually, this is more correct for multi-key updates:

Re: [sqlalchemy] Mutable column_properties

2013-09-12 Thread Jonathan Vanasco
Sweet. This works : results = dbSession.execute( TestClass.__table__\ .update()\ .values( kv = TestClass.__table__.c.kv + sqlalchemy.dialects.postgresql.hstore(sqlalchemy.dialects.postgresql.array(['zz123', 'zz123'])) ) ) stmt = select( [

[sqlalchemy] overriding lazy loading?

2013-09-12 Thread Seth P
Is it possible to override the default loading strategy of a relationship at run-time? For example, I have a relationship that I almost always want to load with lazy='subquery' -- and so I set that as the default loading strategy in the relationship definition -- but in one instance, when I

Re: [sqlalchemy] overriding lazy loading?

2013-09-12 Thread Michael Bayer
have you looked at http://docs.sqlalchemy.org/en/rel_0_8/orm/loading.html ? On Sep 12, 2013, at 9:18 PM, Seth P spadow...@gmail.com wrote: Is it possible to override the default loading strategy of a relationship at run-time? For example, I have a relationship that I almost always want to

[sqlalchemy] how to count function

2013-09-12 Thread Mohsen Pahlevanzadeh
Dear all, I have the following code: // query = self.dbObj.session.query(MaterialsTable) rowCounter = self.dbObj.session.query(MaterialsTable) for attr , val in

Re: [sqlalchemy] overriding lazy loading?

2013-09-12 Thread Seth P
D'oh! I did, though for some reason it didn't occur to me that I could specify .override(lazyload('points')) to override the relationship's default lazy='subquery'. Works like a charm. Thank you. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To

[sqlalchemy] Expire SQLAlchemy session if Oracle node failover

2013-09-12 Thread Devraj Mukherjee
Hi all, We are using SQLAlchemy + cx_Oracle to connect to one of two Oracle nodes (setup to mirror the databases). Connection string as follows: oracle+cx_oracle://%s:%s@