Re: [sqlalchemy] further restricting a query provided as raw sql

2010-04-28 Thread Chris Withers
Michael Bayer wrote: we have the in_() construct. It should be in the ORM and SQL expression tutorials: t1 = Table('mytable', metadata, Column('foo', String)) select([t1]).where(t1.c.foo.in_(['a', 'b', 'c'])) However, that requires table/column objects which I don't have. Are the innards

RE: [sqlalchemy] session lifecycle and wsgi

2010-04-28 Thread King Simon-NFHD78
-Original Message- From: sqlalchemy@googlegroups.com [mailto:sqlalch...@googlegroups.com] On Behalf Of Chris Withers Sent: 28 April 2010 14:37 To: sqlalchemy@googlegroups.com Subject: [sqlalchemy] session lifecycle and wsgi Hi All, I'm still trying to get an answer on this...

[sqlalchemy] ora-28547

2010-04-28 Thread dhanil anupurath
HI I have been using the oracle database for my appliaction. i set the environment variables as export ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/ server export PATH=$PATH:$ORACLE_HOME/bin export LD_LIBRARY_PATH=$ORACLE_HOME/lib export ORACLE_SID=XE I started the

Re: [sqlalchemy] session lifecycle and wsgi

2010-04-28 Thread Diana Clarke
Hi Chris: I'm a bit hesitant to share what I've done, b/c it's still a work in progress etc, but here goes: MySQL MyISAM, wait_timeout=28800 SQLAlchemy 0.5.6, pool_recycle=3600 I've written a few decorators (mostly stolen from SQLAlchemy docs examples): def with_query_write(fn):

Re: [sqlalchemy] session lifecycle and wsgi

2010-04-28 Thread Chris Withers
Diana Clarke wrote: I'm a bit hesitant to share what I've done, b/c it's still a work in progress etc, but here goes: MySQL MyISAM, wait_timeout=28800 You have no transactions, so I'm not sure why you're worrying about them... Switch to InnoDB if you want transactions... Finally,

Re: [sqlalchemy] session lifecycle and wsgi

2010-04-28 Thread jason kirtland
On Wed, Apr 28, 2010 at 7:52 AM, Chris Withers ch...@simplistix.co.uk wrote: Diana Clarke wrote: Finally, we're using pylons and are removing the contextual session in the finally clause of the base controller's __call__ method. class BaseController(WSGIController):    def __call__(self,

Re: [sqlalchemy] session lifecycle and wsgi

2010-04-28 Thread Diana Clarke
Yup, no transactions (legacy, can't switch anytime soon) which is why I didn't originally write any rollback framing... but I was still getting the following error after MySQL raised a 2006 (until app restart), and a quick peek at _handle_dbapi_exception seemed to suggest that I needed to issue

[sqlalchemy] Re: session lifecycle and wsgi

2010-04-28 Thread Laurence Rowe
Chris, This is what the combination of repoze.tm2/transaction and zope.sqlalchemy does for you. You don't have to do anything special other than that. Laurence On Apr 28, 2:37 pm, Chris Withers ch...@simplistix.co.uk wrote: Hi All, I'm still trying to get an answer on this... Am I right in

Re: [sqlalchemy] Re: session lifecycle and wsgi

2010-04-28 Thread Chris Withers
Laurence Rowe wrote: Chris, This is what the combination of repoze.tm2/transaction and zope.sqlalchemy does for you. You don't have to do anything special other than that. It doesn't do the .remove(). BFG currently has a bit of horribleness to make that work. I'd like to get rid of it or make

Re: [sqlalchemy] session lifecycle and wsgi

2010-04-28 Thread Chris Withers
jason kirtland wrote: On Wed, Apr 28, 2010 at 7:52 AM, Chris Withers ch...@simplistix.co.uk wrote: Diana Clarke wrote: Finally, we're using pylons and are removing the contextual session in the finally clause of the base controller's __call__ method. class BaseController(WSGIController):

[sqlalchemy] declarative commit hook - onCommit()?

2010-04-28 Thread Daniel Robbins
Hi All, Let's say that when a database record is added or updated, I need to perform some arbitrary action (in my case, ensuring that data in other tables is consistent with what is being committed.) What mechanisms are suggested for this? I could add a save() method to my declarative class that

Re: [sqlalchemy] declarative commit hook - onCommit()?

2010-04-28 Thread Chris Withers
Daniel Robbins wrote: Let's say that when a database record is added or updated, I need to perform some arbitrary action (in my case, ensuring that data in other tables is consistent with what is being committed.) What mechanisms are suggested for this? Mapper extesions:

Re: [sqlalchemy] declarative commit hook - onCommit()?

2010-04-28 Thread Daniel Robbins
On Wed, Apr 28, 2010 at 10:04 AM, Chris Withers ch...@simplistix.co.uk wrote: Daniel Robbins wrote: Let's say that when a database record is added or updated, I need to perform some arbitrary action (in my case, ensuring that data in other tables is consistent with what is being committed.)

Re: [sqlalchemy] session lifecycle and wsgi

2010-04-28 Thread jason kirtland
On Wed, Apr 28, 2010 at 8:55 AM, Chris Withers ch...@simplistix.co.uk wrote: jason kirtland wrote: On Wed, Apr 28, 2010 at 7:52 AM, Chris Withers ch...@simplistix.co.uk wrote: Diana Clarke wrote: Finally, we're using pylons and are removing the contextual session in the finally clause of

RE: [sqlalchemy] declarative commit hook - onCommit()?

2010-04-28 Thread King Simon-NFHD78
Daniel Robbins wrote: On Wed, Apr 28, 2010 at 10:04 AM, Chris Withers ch...@simplistix.co.uk wrote: Daniel Robbins wrote: Let's say that when a database record is added or updated, I need to perform some arbitrary action (in my case, ensuring that data in other tables is

Re: [sqlalchemy] declarative commit hook - onCommit()?

2010-04-28 Thread Daniel Robbins
On Wed, Apr 28, 2010 at 10:25 AM, King Simon-NFHD78 simon.k...@motorola.com wrote: The declarative docs include an example of using a MapperExtension: http://www.sqlalchemy.org/docs/reference/ext/declarative.html#mapper-con figuration Great, thanks for everyone's help. This is exactly the

[sqlalchemy] Implementing placeholders/get_or_insert over SA

2010-04-28 Thread moranski
I have code which generates mapped classes, some of which are actually already existing in the database ( I the sense that there is a corresponding row ). Example: given the declarative class class Frob(Base): __tablename__ = frobs id = Column(Integer, primary_key = True ) name =

Re: [sqlalchemy] session lifecycle and wsgi

2010-04-28 Thread Michael Bayer
jason kirtland wrote: On Wed, Apr 28, 2010 at 7:52 AM, Chris Withers ch...@simplistix.co.uk wrote: Diana Clarke wrote: Finally, we're using pylons and are removing the contextual session in the finally clause of the base controller's __call__ method. class BaseController(WSGIController):

Re: [sqlalchemy] session lifecycle and wsgi

2010-04-28 Thread Michael Bayer
Diana Clarke wrote: Yup, no transactions (legacy, can't switch anytime soon) which is why I didn't originally write any rollback framing... but I was still getting the following error after MySQL raised a 2006 (until app restart), and a quick peek at _handle_dbapi_exception seemed to suggest

Re: [sqlalchemy] session lifecycle and wsgi

2010-04-28 Thread Chris Withers
Michael Bayer wrote: If finishing with a .remove() is a big deal in your environment, which it seems like it is, you could do a .remove() at the start of the request instead. You really don't need the remove() if you have definitely called commit() or rollback() last, and you have

Re: [sqlalchemy] session lifecycle and wsgi

2010-04-28 Thread Michael Bayer
Chris Withers wrote: Michael Bayer wrote: If finishing with a .remove() is a big deal in your environment, which it seems like it is, you could do a .remove() at the start of the request instead. You really don't need the remove() if you have definitely called commit() or rollback() last,

[sqlalchemy] Select.compare()

2010-04-28 Thread dimazest
Hi all, I faced a problem comparing Selects. It seems that Select.compare() works incorrectly. Here is the code that shows the problem: from sqlalchemy import MetaData from sqlalchemy import Table, Column from sqlalchemy import Integer, String from sqlalchemy import select metadata =

Re: [sqlalchemy] Select.compare()

2010-04-28 Thread Michael Bayer
dimazest wrote: Hi all, I faced a problem comparing Selects. It seems that Select.compare() works incorrectly. Here is the code that shows the problem: from sqlalchemy import MetaData from sqlalchemy import Table, Column from sqlalchemy import Integer, String from sqlalchemy import

[sqlalchemy] Mapper can't map primary key

2010-04-28 Thread Mark
Hi guys, I have the following Table construction: ADMIN_TABLE = Table('admin', bound_meta_data, Column('username', types.VARCHAR(100), primary_key=True), autoload=True, schema=schema) and a mapper as such: