[sqlalchemy] Re: How to instantiate objects of a class mapped against multiple tables?

2009-09-17 Thread bojanb
the solution is the same as that I illustrated in a previous email, that when you map to a JOIN you must place all equivalent columns which you would like populated identically in groups.  This is described athttp://www.sqlalchemy.org/docs/05/mappers.html#mapping-a-class-agains... You're

[sqlalchemy] Re: Self Join

2009-09-17 Thread Michael Bayer
Paulo Aquino wrote: On Tue, Sep 15, 2009 at 5:53 AM, Michael Bayer mike...@zzzcomputing.comwrote: Paulo Aquino wrote: I have 2 tables 'Product' and 'ProductPrice'. I want to get all valid products, a product is valid if it has both a valid 'Selling' and 'Buying' ProductPrice type. A

[sqlalchemy] SQL ALCHEMY instantly refresh

2009-09-17 Thread Christian Démolis
How can i force sqlalchemy to refresh an object when i did a session.query??? Sqlalchemy seems to work with a cache, i want to deal with it. Nota : i use sqlalchemy in non transactional mode Session = scoped_session(sessionmaker(autocommit=True, bind=engine))

[sqlalchemy] Re: How to instantiate objects of a class mapped against multiple tables?

2009-09-17 Thread Michael Bayer
bojanb wrote: the solution is the same as that I illustrated in a previous email, that when you map to a JOIN you must place all equivalent columns which you would like populated identically in groups.  This is described

[sqlalchemy] multiple aggregates query

2009-09-17 Thread Andrey Semyonov
Hi. Since docs for sqlalchemy isn't a clear doc for the beginners I can't find out the way I could implement such a query: SELECT extract(week from to_timestamp(min(datetimeinteger))) as min, extract(week from to_timestamp(max(datetimeinteger))) as max from logtable Database is PGSQL.

[sqlalchemy] Re: multiple aggregates query

2009-09-17 Thread Michael Bayer
Andrey Semyonov wrote: Hi. Since docs for sqlalchemy isn't a clear doc for the beginners I can't find out the way I could implement such a query: SELECT extract(week from to_timestamp(min(datetimeinteger))) as min, extract(week from to_timestamp(max(datetimeinteger))) as max from logtable

[sqlalchemy] Tables reflected in Postgresql + MySQL but not Oracle.

2009-09-17 Thread tomolds
Hi, I have exactly the same schema in Postgresql, MySQL and Oracle. I am reflecting the tables in my application using: self.meta.reflect (bind=self.engine, schema='schem') This works perfectly for MySQL and Postgresql but for Oracle I get no tables reflected and cannot understand why. I can

[sqlalchemy] Comparator factory generator for the substr() of columns

2009-09-17 Thread Kirk Strauser
I'm writing SA classes against a very unnormalized legacy database. Some of our columns comprise several distinct values, and I wanted to take this opportunity to split those into separate properties. I also wanted to be able to search on the values in those properties, and here's my

[sqlalchemy] Re: multiple aggregates query

2009-09-17 Thread Andrey Semyonov
On 17 сен, 19:08, Michael Bayer mike...@zzzcomputing.com wrote: Andrey Semyonov wrote: Hi. Since docs for sqlalchemy isn't a clear doc for the beginners I can't find out the way I could implement such a query: SELECT extract(week from to_timestamp(min(datetimeinteger))) as min,

[sqlalchemy] Re: SQL ALCHEMY instantly refresh

2009-09-17 Thread Alexandre Conrad
2009/9/17 Christian Démolis christiandemo...@gmail.com: How can i force sqlalchemy to refresh an object when i did a session.query??? You may want look at this: http://www.sqlalchemy.org/docs/05/session.html#refreshing-expiring You may, as well, look at expunging. Alex

[sqlalchemy] Re: multiple aggregates query

2009-09-17 Thread Andrey Semyonov
On 17 сен, 19:44, Andrey Semyonov gatekeeper.m...@gmail.com wrote: On 17 сен, 19:08, Michael Bayer mike...@zzzcomputing.com wrote: Andrey Semyonov wrote: Hi. Since docs for sqlalchemy isn't a clear doc for the beginners I can't find out the way I could implement such a query:

[sqlalchemy] Re: SQL ALCHEMY instantly refresh

2009-09-17 Thread Christian Démolis
Bonjour, Tu es français je pense au vu de ton prénom. Je continue donc en français. En fait j'ai 25000 lignes de codes derrière moi et j'aimerai éviter d'avoir à ajouter tous les refresh ou les session.query().populate_existing() partout dans mon code J'ai tenté en vain de surcharger la méthode

[sqlalchemy] Re: SQL ALCHEMY instantly refresh

2009-09-17 Thread Michael Bayer
Alexandre Conrad wrote: Christian, 2009/9/17 Christian Démolis christiandemo...@gmail.com: Bonjour, Tu es français je pense au vu de ton prénom. Je continue donc en français. Nice guess. I understand it feels more comfortable writing in French rather than in English, but many people

[sqlalchemy] Concurrent Update Errors

2009-09-17 Thread gizli
Hi guys, I have a couple of questions about a recent concurrency test I did on SA. Someone in our team ran into a very intermittent issue where a certain operation he tried doing failed by ConcurrentUpdateError. I wrote a simple thread that can do query/update/insert/commit/rollback operations

[sqlalchemy] Re: Concurrent Update Errors

2009-09-17 Thread Michael Bayer
gizli wrote: t1.delete(obj) t2.delete(obj) t2.commit() t1.commit() I also forgot to mention that you can always use query.delete() or table.delete() to get a standard relational delete, though it does not offer in-python cascading. This delete translates directly to DELETE with the given

[sqlalchemy] Re: Concurrent Update Errors

2009-09-17 Thread gizli
Thanks for the excellent information Michael. Will need to think about this and post again if I have further questions. As for the delete/rm discussion, I guess it depends on your use case. I usually run rm with -f flag which fails silently if no file is found. But I get your point and you also

[sqlalchemy] Re: Tables reflected in Postgresql + MySQL but not Oracle.

2009-09-17 Thread Michael Bayer
On Sep 17, 2009, at 11:20 AM, tomolds wrote: Hi, I have exactly the same schema in Postgresql, MySQL and Oracle. I am reflecting the tables in my application using: self.meta.reflect (bind=self.engine, schema='schem') This works perfectly for MySQL and Postgresql but for Oracle I get

[sqlalchemy] testing web.py apps, with database

2009-09-17 Thread Sean
Hi, I'm trying to test my web.py app, including its database functionality. I would like to use a test database for this purpose, but it seems like the standard web.py way of doing things is to hardcode the database connection in something like a config.py file. What's the best way to test a