[sqlalchemy] Re: Creating Custom SQL

2010-06-04 Thread Jan-Eric
Thank you for your reply. Is this available for version 0.6 only ? On Jun 3, 5:41 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Jun 3, 2010, at 5:06 AM, Jan-Eric wrote: Hi! I have a problem with constructing a custom SQL statement. I would like to create the following SQL

RE: [sqlalchemy] SA on MySQL 3.23

2010-06-04 Thread King Simon-NFHD78
-Original Message- From: sqlalchemy@googlegroups.com [mailto:sqlalch...@googlegroups.com] On Behalf Of Michael Bayer Sent: 03 June 2010 19:38 To: sqlalchemy@googlegroups.com Subject: Re: [sqlalchemy] SA on MySQL 3.23 On Jun 3, 2010, at 1:15 PM, King Simon-NFHD78 wrote: Hi,

Re: [sqlalchemy] Re: Creating Custom SQL

2010-06-04 Thread Michael Bayer
its in 0.5. Make sure you use the passed in compiler to compile sub-expressions, i.e. compiler.process(expr) instead of str(expr). On Jun 4, 2010, at 5:45 AM, Jan-Eric wrote: Thank you for your reply. Is this available for version 0.6 only ? On Jun 3, 5:41 pm, Michael Bayer

Re: [sqlalchemy] SA on MySQL 3.23

2010-06-04 Thread Michael Bayer
On Jun 4, 2010, at 6:54 AM, King Simon-NFHD78 wrote: I'll happily try any suggestions you've got :-) I couldn't see anything in the MySQL docs that suggested an alternative to the CAST function, so it seems reasonable to just omit it for older MySQL servers. I applied the attached patch,

[sqlalchemy] What is a good pattern for using sqlalchemy+psycopg2+gevent in a pylons app

2010-06-04 Thread afrotypa
Hi All, For a while I have been toying with the idea of developing/running a database (postgresql backend) driven WSGI app using an async python WSGI server such as gevent. Now that the newer psycopg2 (=2.2.0) drivers provide coroutine support (via a hook which makes c extension database

[sqlalchemy] Re: Questions about session

2010-06-04 Thread Az
Sorry, meant to reply to you Michael... ended up replying to myself! --- Firstly, apologies if I'm demanding too much but basically I'm quite a beginner at Python programming and this is for a University project, which is why I'm keen to get this done (due in a few days!). So I hope you won't

RE: [sqlalchemy] SA on MySQL 3.23

2010-06-04 Thread King Simon-NFHD78
-Original Message- From: sqlalchemy@googlegroups.com [mailto:sqlalch...@googlegroups.com] On Behalf Of Michael Bayer Sent: 04 June 2010 14:42 To: sqlalchemy@googlegroups.com Subject: Re: [sqlalchemy] SA on MySQL 3.23 On Jun 4, 2010, at 6:54 AM, King Simon-NFHD78 wrote:

[sqlalchemy] Couple of breaking changes in 0.6

2010-06-04 Thread Gunnlaugur Briem
Hi, I'm finally adapting our codebase to SqlAlchemy 0.6, and I've found a couple of breaking changes that are not documented in http://www.sqlalchemy.org/trac/wiki/06Migration First, ResultProxy.keys is now a method returning a list, not a list- valued attribute, so expressions like k in

[sqlalchemy] Declarative with mix-in and __table__ fails [patch]

2010-06-04 Thread Gunnlaugur Briem
Hi, if I declaratively map a class with a mix-in and with a __table__ definition that contains the columns in the mix-in, like so: class MyMixin(object): id = Column(Integer, primary_key=True) def foo(self): return 'bar'+str(self.id) class MyModel(Base,MyMixin): __table__ =

[sqlalchemy] EXISTS statements with any(), but with a join

2010-06-04 Thread Kent
Say I track Inventory with three classes: Product, Inventory, Location This any() expression yields the following output. session.query(Product).filter(Product.inventory.any(Location.siteid==u'EAST')).all() SELECT ... FROM products WHERE EXISTS (SELECT 1 FROM inventory, locations WHERE

Re: [sqlalchemy] EXISTS statements with any(), but with a join

2010-06-04 Thread Conor
On 06/04/2010 03:13 PM, Kent wrote: Say I track Inventory with three classes: Product, Inventory, Location This any() expression yields the following output. session.query(Product).filter(Product.inventory.any(Location.siteid==u'EAST')).all() SELECT ... FROM products WHERE EXISTS (SELECT

Re: [sqlalchemy] EXISTS statements with any(), but with a join

2010-06-04 Thread Kent Bower
Nice. That might come in very useful, thanks. However, I can't quite get the second approach to work: exq=DBSession.query(Inventory).join(Location).filter(Location.siteid=='03').correlate(Product).subquery() DBSession.query(Product).filter(exists(exq)).all() Traceback (most recent call last):

Re: [sqlalchemy] Re: Questions about session

2010-06-04 Thread Conor
On 06/03/2010 02:33 PM, Az wrote: Firstly, apologies if I'm demanding too much but basically I'm quite a beginner at Python programming and this is for a University project, which is why I'm keen to get this done (due in a few days!). So I hope you won't mind me asking some questions that may

Re: [sqlalchemy] Couple of breaking changes in 0.6

2010-06-04 Thread Michael Bayer
On Jun 4, 2010, at 1:16 PM, Gunnlaugur Briem wrote: Hi, I'm finally adapting our codebase to SqlAlchemy 0.6, and I've found a couple of breaking changes that are not documented in http://www.sqlalchemy.org/trac/wiki/06Migration First, ResultProxy.keys is now a method returning a list,

Re: [sqlalchemy] Declarative with mix-in and __table__ fails [patch]

2010-06-04 Thread Michael Bayer
On Jun 4, 2010, at 3:21 PM, Gunnlaugur Briem wrote: Hi, if I declaratively map a class with a mix-in and with a __table__ definition that contains the columns in the mix-in, like so: class MyMixin(object): id = Column(Integer, primary_key=True) def foo(self): return

Re: [sqlalchemy] SA on MySQL 3.23

2010-06-04 Thread Michael Bayer
On Jun 4, 2010, at 12:43 PM, King Simon-NFHD78 wrote: If you're more comfortable with a version that just doesn't call _check_unicode_returns, or that catches the exception, either would be fine with me. I just sent the first thing I tried that seemed to work. I agree that silently

Re: [sqlalchemy] EXISTS statements with any(), but with a join

2010-06-04 Thread Conor
On 06/04/2010 03:56 PM, Kent Bower wrote: Nice. That might come in very useful, thanks. However, I can't quite get the second approach to work: exq=DBSession.query(Inventory).join(Location).filter(Location.siteid=='03').correlate(Product).subquery()

[sqlalchemy] Re: Declarative with mix-in and __table__ fails [patch]

2010-06-04 Thread Gunnlaugur Briem
On Jun 4, 9:23 pm, Michael Bayer mike...@zzzcomputing.com wrote: as long as all tests pass it is fine.  If you could give me a patch that includes a test for this in test_declarative, that would be supremely helpful (if you want to make a trac ticket and target it at the 0.6.2 milestone).