2 messages in com.googlegroups.sqlalchemy[sqlalchemy] problems with exists| From | Sent On | Attachments |
|---|---|---|
| Manlio Perillo | 23 Feb 2007 07:25 | |
| Michael Bayer | 23 Feb 2007 10:44 |
| Subject: | [sqlalchemy] problems with exists![]() |
|---|---|
| From: | Manlio Perillo (manl...@gmail.com) |
| Date: | 02/23/2007 07:25:15 AM |
| List: | com.googlegroups.sqlalchemy |
Hi.
I'm having problems with the exists clause.
Here is the code:
from sqlalchemy import *
db = create_engine('sqlite:///', echo=True) metadata = BoundMetaData(db)
test = Table( 'test', metadata, Column('id', Integer, primary_key=True), Column('x', String), Column('y', String) )
metadata.create_all() try: conn = db.contextual_connect()
# i = test.insert() # conn.execute(i, x='x', y='z')
# Test if select works without a from clause query = select([text('1 + 1')]) print conn.execute(query).scalar()
query = select( [exists( [test.c.id], and_( test.c.x == 'x', test.c.y == 'y' ) )] ) print conn.execute(query).scalar() finally: metadata.drop_all()
The generated query is:
SELECT EXISTS (SELECT test.id AS id FROM test WHERE test.x = ? AND test.y = ?) FROM (SELECT test.id AS id FROM test WHERE test.x = ? AND test.y = ?)
This is wrong (it works on SQLite but Postgres raises an error). I have tried to add a from_obj=[], but it does not works.
Thanks and regards Manlio Perillo
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to sqla...@googlegroups.com
To unsubscribe from this group, send email to
sqla...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---




