[sqlalchemy] association_proxy usage in non-declarative style

2012-01-11 Thread Phazorx
Hello, i am trying to figure out how association_proxy() could be used in case of regular rather than declarative style definitions. I can't figure out what can be done to mitigate the issue and hence i seek help here. Thanks in advance... The code below is copy/pasted sample from the official

[sqlalchemy] Select ... for update of

2012-01-11 Thread Vlad K.
I need to select for update but locking the row only in one table in a query with outer joins. I'm using PostgreSQL backend. It has to be outer join, so I need FOR UPDATE OF [tablename]. How do I do that with SQLA? So far I was using Query.with_lockmode(update), but I can't specify the table

[sqlalchemy] Re: sql hashed tables

2012-01-11 Thread Mason
Thanks for the reply. I will use partition table in mysql instead and just let the db deals with the hashed tables. On Jan 9, 6:30 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Jan 9, 2012, at 9:07 PM, Mason wrote: Hi I have 100 tables that go from user_00 to user_99 (based

[sqlalchemy] insert or update on duplicate key

2012-01-11 Thread Mason
Hi, I have been looking at the group archive and googling around a bit, but it seems like if I want to do insert to table if row doesn't exist, otherwise update a field in the row is not really possible. I end up doing something like below. def _add_index(self, src_id, tar_id): row

Re: [sqlalchemy] insert or update on duplicate key

2012-01-11 Thread Michael Bayer
On Jan 11, 2012, at 7:54 PM, Mason wrote: Hi, I have been looking at the group archive and googling around a bit, but it seems like if I want to do insert to table if row doesn't exist, otherwise update a field in the row is not really possible. I end up doing something like below.

RE: [sqlalchemy] insert or update on duplicate key

2012-01-11 Thread Jackson, Cameron
That looks like an OK way to do things to me, but I'm by no means an expert. Depending on memory limitations, and how big the table is going to get, you might be able to do something like: * Store all index objects at application startup: self.indices = self.session.query(Index).all() *

RE: [sqlalchemy] insert or update on duplicate key

2012-01-11 Thread Jackson, Cameron
Bah! Mike beat me to it again! :P -Original Message- From: sqlalchemy@googlegroups.com [mailto:sqlalchemy@googlegroups.com] On Behalf Of Michael Bayer Sent: Thursday, 12 January 2012 12:07 PM To: sqlalchemy@googlegroups.com Subject: Re: [sqlalchemy] insert or update on duplicate key

Re: [sqlalchemy] insert or update on duplicate key

2012-01-11 Thread Michael Bayer
OK, I'll give you like 30 minutes next time ! Sorry I'm not used to having much help here ! Thanks ! On Jan 11, 2012, at 8:08 PM, Jackson, Cameron wrote: Bah! Mike beat me to it again! :P -Original Message- From: sqlalchemy@googlegroups.com [mailto:sqlalchemy@googlegroups.com]