[sqlalchemy] Using SQLAlchemy with multiple classes/modules

2008-11-17 Thread Power Button
Hi folks, I am quite new to Python and SQLAlchemy and I have a question about to setup the project structure. I have my main python script and then a bunch of classes - each defined in their own class file and stored in packages (directories) like so /root myApp.py modules/ class1.py

[sqlalchemy] Customize query filters

2008-11-17 Thread Iain
I was wondering if anyone is aware of a way that I can customize the way query filters are written - possibly by some sort of customization of table columns? The issue is that I have some odd data/column types that can't be compared directly. That is, SELECT * WHERE column1=value1 will not work

[sqlalchemy] Re: Customize query filters

2008-11-17 Thread Michael Bayer
On Nov 17, 2008, at 7:50 AM, Iain wrote: I was wondering if anyone is aware of a way that I can customize the way query filters are written - possibly by some sort of customization of table columns? The issue is that I have some odd data/column types that can't be compared directly. That

[sqlalchemy] Re: Using SQLAlchemy with multiple classes/modules

2008-11-17 Thread Michael Bayer
On Nov 17, 2008, at 7:17 AM, Power Button wrote: What I have tried is putting all the setup instructions into a class and instantiating this in myApp.py. This doesn't make it global to all the modules though. Do I need to pass this object around to all classes as arguments to __init__() in

[sqlalchemy] odd error message from query

2008-11-17 Thread Faheem Mitha
Hi, [I was told on IRC this was not worth bothering with, but since I've already written it, I'm sending this out. Please ignore if useless.] I mistakenly did query = session.query(Patient).filter_by(id==John).all() and got the curious response: TypeError: filter_by() takes exactly 1

[sqlalchemy] Re: odd error message from query

2008-11-17 Thread Michael Bayer
On Nov 17, 2008, at 4:23 PM, Faheem Mitha wrote: Hi, [I was told on IRC this was not worth bothering with, but since I've already written it, I'm sending this out. Please ignore if useless.] I mistakenly did query = session.query(Patient).filter_by(id==John).all() and got the

[sqlalchemy] Issues with Connection Pools

2008-11-17 Thread Dusty Phillips
1 = noah;'}) self.assert_(content.startswith(QueryResults)) threads = [] for i in range(20): thread = BridgeRequest() thread.start() threads.append(thread) for thread in threads: thread.join() I get a bunch of errors like this on the server:

[sqlalchemy] Re: Issues with Connection Pools

2008-11-17 Thread Michael Bayer
ProgrammingError comes from the DBAPI, so thats the connect exception. SQLA re-throws it which is why the stack trace isn't entirely accurate. On Nov 17, 2008, at 5:24 PM, Dusty Phillips wrote: 1 = noah;'}) self.assert_(content.startswith(QueryResults)) threads = [] for

[sqlalchemy] Re: Customize query filters

2008-11-17 Thread Iain
Fantastic, it works just the way I was hoping. Thanks. I ended up using the mapper rather than taking the declarative route (especially since I'm extracting table structures via metadata), but as far as I can tell it all works fine - just in case anyone wants to see an example of it (missing

[sqlalchemy] adding objects to table only once

2008-11-17 Thread Faheem Mitha
Hi, I've written a session transcript to init db tables and add objects (well, rows) to the tables. The issue I'm currently facing is how to make the creating and populating the tables section of the script a no-op when the objects exist. If the tables already exist sqlalchemy does nothing,