[sqlalchemy] Re: Somewhat complex union_all() question

2009-08-27 Thread Seth
Mike, Very helpful! Seems to work great. Wanna give me a tip on how to make the user's table join to this query via the user_id so that I can access the user's information at something like q.user.email? Seth On Aug 26, 9:22 pm, Mike Conley mconl...@gmail.com wrote: or should be a little

[sqlalchemy] Problem with defining relations between inherited classes

2009-08-27 Thread Tefnet Developers
Hi, I have a problem with such program (available at http://filip.math.uni.lodz.pl/relation_problem.py): = Fails with Python-2.5.4 and SQLAlchemy-0.5.5 import sqlalchemy import sqlalchemy.ext.declarative ''' This program

[sqlalchemy] Re: Problem with defining relations between inherited classes

2009-08-27 Thread Michael Bayer
Tefnet Developers wrote: class Location(PhysObject): Id = sqlalchemy.Column(sqlalchemy.types.Integer, sqlalchemy.ForeignKey(PhysObject.Id), primary_key=True) description = sqlalchemy.Column( sqlalchemy.types.String(128)) PhysObject.location = sqlalchemy.orm.relation(

[sqlalchemy] Re: Most elegant SqlSoup solution cope with legacy client db tables without primary keys?

2009-08-27 Thread Michael Bayer
Xavian wrote: 1) Is there a way to give SqlSoup hints on how to handle the lack of a primary key so that the selection and mapping magic will work correctly instead of raising a PKNotFoundError exception? SQLSoup tables are all mapped classes. a mapper() always needs a primary key. so at

[sqlalchemy] Re: How to organize a Data Base Access layer?

2009-08-27 Thread Michael Bayer
why not use a high speed database like an in-memory SQLite db for running your tests ? 一首诗 wrote: I am using SqlAlchemy and I used to access database directly from business layer directly by calling SqlAlchemy API. But then I found that would cause too much time to run all my test cases

[sqlalchemy] Re: potential oracle character column reflection bug?

2009-08-27 Thread jek
On Aug 26, 6:01 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Aug 26, 2009, at 8:53 PM, chris e wrote: I just checked the trunk, it the same reflection code is in place, as far as the column length is concerned. To me the question is, should sqlalchemy be aware of Char vs Byte

[sqlalchemy] Problem with non-pk sequences in relations on MSSQL

2009-08-27 Thread Y3s
Hi all, I'm having a problem with a non primary key sequence involved in a relation. The failing environment is sqlalchemy 0.5.5 on ms sql server 2005 with pymssql 0.8. I have a parent table with its own pk and a sequence field and a child table with a pk composed by the parent's sequence (NOT

[sqlalchemy] Re: Problem with non-pk sequences in relations on MSSQL

2009-08-27 Thread Y3s
On Aug 27, 9:05 pm, Michael Bayer mike...@zzzcomputing.com wrote: Y3s wrote: It seems that the child instances are not updated with the right sequence number. Moreover, if I turn the parent's id column into the primary key, the error disappears. Is it a known issue? Can i fix it in

[sqlalchemy] Re: potential oracle character column reflection bug?

2009-08-27 Thread chris e
If we prefer it to be characters, then we should probably use CHAR_LENGTH instead of DATA_LENGHT when reflecting, and add the CHAR specifier to the column generators. I can put together a patch if that helps. On Aug 27, 10:02 am, jek jason.kirtl...@gmail.com wrote: On Aug 26, 6:01 pm,

[sqlalchemy] session clean-up problem?

2009-08-27 Thread Gloria W
Hi all, We're hitting a weird bug here. I'm doing a standard query with filters, and this is appended to the end: resultObj = resultObj.order_by(Member.lastname, Member.firstname, Member.middleinitial,

[sqlalchemy] Re: Problem with non-pk sequences in relations on MSSQL

2009-08-27 Thread Michael Bayer
Y3s wrote: It seems that the child instances are not updated with the right sequence number. Moreover, if I turn the parent's id column into the primary key, the error disappears. Is it a known issue? Can i fix it in some way (except for normalize the db schema)? I dont believe MSSQL

[sqlalchemy] Re: Somewhat complex union_all() question

2009-08-27 Thread Mike Conley
OK, I can mostly answer my own question q1=session.query(P1.userid,P1.extra,P1.title,P1.body) q2=session.query(P2.userid,'X',P2.title,P2.body) q3=session.query(P3.userid,'X',P3.title,P3.body) subq=q1.union_all(q2,q3).subquery() q = session.query(USER.email, subq).join((subq,

[sqlalchemy] Re: session clean-up problem?

2009-08-27 Thread Gloria
Yes, I'm using this in a CherryPy threaded web app. One request could take a long time, based on search criteria. But each query runs in it's own thread, with it's own isolated session. I have a sessionmaker in my constructor: def __init__(self,dsn): self.engine =

[sqlalchemy] Re: session clean-up problem?

2009-08-27 Thread Gloria
OK, so is the solution to run these in separate processes instead? Is this a GIL limitation? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to

[sqlalchemy] Custom attribute in table class

2009-08-27 Thread thatsanicehatyouhave
Hi, I'm trying to create a custom/derived attribute on a table class. This is what I have defined: class Plate(Base): __tablename__ = 'plate' __table_args__ = {'autoload' : True} class Design(Base): __tablename__ = 'design' __table_args__ = {'autoload' : True}

[sqlalchemy] Re: session clean-up problem?

2009-08-27 Thread Gloria
OK, so is the solution to run these in separate processes instead? Is this a GIL limitation? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to

[sqlalchemy] Re: session clean-up problem?

2009-08-27 Thread Gloria
Wow, my browser is posting multiple times when I have something else refreshing another screen in FF. Weird! On Aug 27, 7:16 pm, Gloria strang...@comcast.net wrote: Fantastic! I'll do this and respknd again tomorrow. Thanks for your help, --~--~-~--~~~---~--~~

[sqlalchemy] Re: session clean-up problem?

2009-08-27 Thread Gloria
Fantastic! I'll do this and respknd again tomorrow. Thanks for your help, --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To

[sqlalchemy] Re: session clean-up problem?

2009-08-27 Thread Gloria
Fantastic! I'll do this and respknd again tomorrow. Thanks for your help, --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To

[sqlalchemy] Re: Somewhat complex union_all() question

2009-08-27 Thread Mike Conley
Assuming a declarative based class USER exists, then you can join each of the queries q1, q2, q3 to USER like this: q1 = session.query(P1.userid,P1.extra,P1.title,P1.body,USER.email) q1 = q1.join((USER,USER.userid==P1.userid)) q2 = session.query(P2.userid,'X',P2.title,P2.body,USER.email) q2 =

[sqlalchemy] How to label text columns in a query

2009-08-27 Thread Mike Conley
Here is the problem I have two mapped classes (A and B) and want to create a union_all query. q1 = session.query(A.data, '\'A\'') # includes a literal 'A' in the result q2 = session.query(B.data, '\'B\'') qry = q1.union_all(q2) generates this SQL: SELECT anon_1.data, 'A' FROM (SELECT a.data AS

[sqlalchemy] Re: session clean-up problem?

2009-08-27 Thread Michael Bayer
Gloria W wrote: Hi all, We're hitting a weird bug here. I'm doing a standard query with filters, and this is appended to the end: resultObj = resultObj.order_by(Member.lastname, Member.firstname, Member.middleinitial,

[sqlalchemy] Re: session clean-up problem?

2009-08-27 Thread Michael Bayer
Gloria wrote: Yes, I'm using this in a CherryPy threaded web app. One request could take a long time, based on search criteria. But each query runs in it's own thread, with it's own isolated session. right but, a set of threads could be hanging for a long time, is my point. like if hitting

[sqlalchemy] Re: session clean-up problem?

2009-08-27 Thread Gloria
Yes, I'm using this in a CherryPy threaded web app. One request could take a long time, based on search criteria. But each query runs in it's own thread, with it's own isolated session. I have a sessionmaker in my constructor: def __init__(self,dsn): self.engine =

[sqlalchemy] Re: session clean-up problem?

2009-08-27 Thread Gloria
Yes, I'm using this in a CherryPy threaded web app. One request could take a long time, based on search criteria. But each query runs in it's own thread, with it's own isolated session. I have a sessionmaker in my constructor: def __init__(self,dsn): self.engine =

[sqlalchemy] Re: session clean-up problem?

2009-08-27 Thread Michael Bayer
Gloria wrote: OK, so is the solution to run these in separate processes instead? Is this a GIL limitation? not at all. you would need to a. determine that you do in fact have queries that are taking exceedingly long to complete and then b. repair those queries so that they return in a

[sqlalchemy] Re: session clean-up problem?

2009-08-27 Thread Gloria
Yes, I'm using this in a CherryPy threaded web app. One request could take a long time, based on search criteria. But each query runs in it's own thread, with it's own isolated session. I have a sessionmaker in my constructor: def __init__(self,dsn): self.engine =

[sqlalchemy] Re: session clean-up problem?

2009-08-27 Thread Gloria
OK, so is the solution to run these in separate processes instead? Is this a GIL limitation? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to

[sqlalchemy] Re: session clean-up problem?

2009-08-27 Thread Gloria
Fantastic! I'll do this and respknd again tomorrow. Thanks for your help, --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To

[sqlalchemy] Re: How to label text columns in a query

2009-08-27 Thread Michael Bayer
On Aug 27, 2009, at 7:55 PM, Mike Conley wrote: Here is the problem I have two mapped classes (A and B) and want to create a union_all query. q1 = session.query(A.data, '\'A\'') # includes a literal 'A' in the result q2 = session.query(B.data, '\'B\'') qry = q1.union_all(q2)

[sqlalchemy] Re: session clean-up problem?

2009-08-27 Thread Gloria
OK, so is the solution to run these in separate processes instead? Is this a GIL limitation? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to