Re: [sqlalchemy] distinct query

2010-03-18 Thread Mike Conley
Did you try qry = session.query(AssetCategory).join(Asset).join(Shot).filter(Shot.id==1).distinct() qry = qry.filter(Shot.id==shot_id_of_interest) that generates SELECT DISTINCT "AssetCategory".id AS "AssetCategory_id" FROM "AssetCategory" JOIN "Asset" ON "AssetCategory".id = "Asset".category_id

[sqlalchemy] Re: double clause in outer join

2010-03-18 Thread ellonweb
Silly mistake, this works fine now, thanks! On Mar 19, 12:53 am, Michael Bayer wrote: > On Mar 18, 2010, at 8:28 PM, ellonweb wrote: > > > > > Hi, > > I have a query object to which I'm performing the following join and > > filter: > >        Q = Q.outerjoin(Table.history_loader) > >        Q = Q

Re: [sqlalchemy] double clause in outer join

2010-03-18 Thread Michael Bayer
On Mar 18, 2010, at 8:28 PM, ellonweb wrote: > Hi, > I have a query object to which I'm performing the following join and > filter: >Q = Q.outerjoin(Table.history_loader) >Q = Q.filter(TableHistory.tick == 123) > Table.history_loader is a dynamic loader that maps the two tables >

[sqlalchemy] double clause in outer join

2010-03-18 Thread ellonweb
Hi, I have a query object to which I'm performing the following join and filter: Q = Q.outerjoin(Table.history_loader) Q = Q.filter(TableHistory.tick == 123) Table.history_loader is a dynamic loader that maps the two tables based on their id property. This produces the following SQ

Re: [sqlalchemy] AttributeError: 'cx_Oracle.LOB' object has no attribute 'decode'

2010-03-18 Thread Michael Bayer
that should be fixed in latest tip. get it from the download page. chris e wrote: > I am running into the following error running under mod_wsgi, and > against an Oracle Database, using cx_Oracle > > I'm running the following query: > > result = select([TABLES.SYSTEM_CONFIG.c.value], > > TABLES.

[sqlalchemy] AttributeError: 'cx_Oracle.LOB' object has no attribute 'decode'

2010-03-18 Thread chris e
I am running into the following error running under mod_wsgi, and against an Oracle Database, using cx_Oracle I'm running the following query: result = select([TABLES.SYSTEM_CONFIG.c.value], TABLES.SYSTEM_CONFIG.c.key=='email_address').execute().fetchall() The table is defined as follows: SY

[sqlalchemy] Re: "in_()" operator is not currently implemented for many-to-one-relations - alternatives?

2010-03-18 Thread Stodge
Thanks that worked beautifully. On a similar note, how would I match documents with only the tags that I specify in the list? My naive attempt is: for tag in tag_list: session.query(Document).join(Document.tags).filter_by(tag=tag) But that doesn't work. On Mar 15, 10:54 am, "Michael Bayer"

[sqlalchemy] distinct query

2010-03-18 Thread Sebastian Elsner
Hello, I am stuck here with a query, it't not too complicated I think, but I dont get it... I have three Class/table mappings: Shots, Assets, which belong to a Shot (1:n) and AssetCategories, which are owned by Assets (n:1) The objective is: For a given shot instance get all distinct Asset

[sqlalchemy] Re: Calling a function after every new connection is created

2010-03-18 Thread chris e
Thanks, that's perfect. I knew it had to be in the API somewhere, but I couldn't find it. On Mar 18, 5:44 am, Michael Bayer wrote: > On Mar 17, 2010, at 9:45 PM, chris e wrote: > > > > > Because of the way that we have our Oracle database setup, I have to > > do the following to force every conn

Re: [sqlalchemy] Problem with Foreign Key

2010-03-18 Thread masetto
Damn, your're right! Mea culpa :P Thanks! Now it's working again On Thu, Mar 18, 2010 at 6:27 PM, Michael Bayer wrote: > masetto wrote: > > Hi all, > > > > i am new to SQLAlchemy (simply wonderful!), and i'm writing some > > python scripts to do some experiment. > > > > I've written a SINGLE py

[sqlalchemy] Re: confusion with outer join setup

2010-03-18 Thread Michael Bayer
On Mar 18, 12:24 pm, Jonathan Vanasco wrote: > let me simplify this , maybe it'll make sense to someone presented > differently: > > # do we need to restrict this within a date range ? > dates= [] > if date_start: >         dates.append( class_a.timestamp_registered >= > date_start ) > if date_e

Re: [sqlalchemy] Problem with Foreign Key

2010-03-18 Thread Michael Bayer
masetto wrote: > Hi all, > > i am new to SQLAlchemy (simply wonderful!), and i'm writing some > python scripts to do some experiment. > > I've written a SINGLE python module with two classes which define two > different tables (declarative_base) with a simple relationship and a > single Foreign Key

Re: [sqlalchemy] Re: defer relation load in a query more than one relation away

2010-03-18 Thread Michael Bayer
Kent wrote: > I should have mentioned that even when I was using lazyload() I was > getting the same problem, but I think I corrected my problem with > this: > > > o=DBSession.query(Order).options(lazyload(Order.orderdetails,OrderDetail.product)).get(u'SALE35425') > > I think I understand better no

[sqlalchemy] Problem with Foreign Key

2010-03-18 Thread masetto
Hi all, i am new to SQLAlchemy (simply wonderful!), and i'm writing some python scripts to do some experiment. I've written a SINGLE python module with two classes which define two different tables (declarative_base) with a simple relationship and a single Foreign Key and everything WORKS fine as

[sqlalchemy] Re: confusion with outer join setup

2010-03-18 Thread Jonathan Vanasco
let me simplify this , maybe it'll make sense to someone presented differently: # do we need to restrict this within a date range ? dates= [] if date_start: dates.append( class_a.timestamp_registered >= date_start ) if date_end: dates.append( class_a.timestamp_registered <= date_e

[sqlalchemy] Re: defer relation load in a query more than one relation away

2010-03-18 Thread Kent
I should have mentioned that even when I was using lazyload() I was getting the same problem, but I think I corrected my problem with this: o=DBSession.query(Order).options(lazyload(Order.orderdetails,OrderDetail.product)).get(u'SALE35425') I think I understand better now: is it correct that yo

Re: [sqlalchemy] not-null constraint violation in 0.6beta1

2010-03-18 Thread Christoph Ludwig
On Sat, Mar 13, 2010 at 08:14:46PM -0500, Michael Bayer wrote: > > On Mar 13, 2010, at 6:45 PM, Christoph Ludwig wrote: > > > Hi, > > > > I have an application that used to work fine with SQLAlchemy > > 0.5.6. With 0.6beta1 I observe commit failures when I try to update > > references in a 1-to-

Re: [sqlalchemy] Assertion Error

2010-03-18 Thread Michael Bayer
rajasekhar911 wrote: > Hi guys > > I got this weird AsserstionError and KeyError. It says it is ignored. > The class Credential is a mapped as a relation to the parent class. > > credential=relation(Credential, \ > primaryjoin=id == Credential.n_id,\ > foreig

[sqlalchemy] Assertion Error

2010-03-18 Thread rajasekhar911
Hi guys I got this weird AsserstionError and KeyError. It says it is ignored. The class Credential is a mapped as a relation to the parent class. credential=relation(Credential, \ primaryjoin=id == Credential.n_id,\ foreign_keys=[Credential.n_id],\

[sqlalchemy] Re: ms sql server schema.sequence

2010-03-18 Thread Tan Yi
Thanks a lot, this is the information I am looking for! -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googl

Re: [sqlalchemy] Calling a function after every new connection is created

2010-03-18 Thread Michael Bayer
On Mar 17, 2010, at 9:45 PM, chris e wrote: > Because of the way that we have our Oracle database setup, I have to > do the following to force every connection to use exact cursor > sharing. > >dbapi = engine.dialect.dbapi >orig_connect = dbapi.connect >def exact_connect(*args, **kwa