[sqlalchemy] Error - class 'sqlalchemy.exc.OperationalError': (OperationalError) (2006, 'MySQL server has gone away')
sorry if this is addressed, but i'm running apache2 SQLAlchemy 0.5.8 Pylons 1.0 Python 2.5.2 and on a simple page (just retrieve data from DB), I get: Error - class 'sqlalchemy.exc.OperationalError': (OperationalError) (2006, 'MySQL server has gone away') every few other requests, not after a long time as other posts I've searched for. I still added sqlalchemy.pool_recycle = 1800 but that did not fix the issue. After a fresh apache restart, every 5th or 6th requests gets a 500 from the above error. thanks -- 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...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
Re: [sqlalchemy] Error - class 'sqlalchemy.exc.OperationalError': (OperationalError) (2006, 'MySQL server has gone away')
hey, Linux ded-230-114 2.6.30-bpo.1-686 #1 SMP Mon Aug 17 14:57:26 UTC 2009 i686 GNU/Linux thanks! On Thu, Oct 14, 2010 at 5:56 PM, Warwick Prince warwi...@mushroomsys.comwrote: HiTimmy What OS are you running under for each? Cheers Warwick *Warwick Prince* Managing Director mobile: +61 411 026 992 skype: warwickprince [image: If you have Skype installed, click here to call me now!] [image: Mushroom Systems] phone: +61 7 3102 3730 fax: +61 7 3319 6734 web: www.mushroomsys.com [image: I'm Green with Little Green Genie]http://littlegreengenie.com/index.html?referer=WARWICKP On 15/10/2010, at 7:48 AM, Timmy Chan wrote: sorry if this is addressed, but i'm running apache2 SQLAlchemy 0.5.8 Pylons 1.0 Python 2.5.2 and on a simple page (just retrieve data from DB), I get: Error - class 'sqlalchemy.exc.OperationalError': (OperationalError) (2006, 'MySQL server has gone away') every few other requests, not after a long time as other posts I've searched for. I still added sqlalchemy.pool_recycle = 1800 but that did not fix the issue. After a fresh apache restart, every 5th or 6th requests gets a 500 from the above error. thanks -- 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...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en. -- 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...@googlegroups.comsqlalchemy%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en. -- 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...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] Polymorphic on another table?
i have 4 tables, a, b, c, d. a has one-to-many relation with b, b with one-to-one relationship with c, c is a polymorphic on a.type, with d being one of the polymorphic types. is there a way to implement this? details: this is what im trying to do in sqlalchemy: a = Table('a', metadata, Column( 'id', Integer(), primary_key=True ), Column( 'type', UnicodeText() ) ) b = Table('b', metadata, Column( 'id', Integer(), primary_key=True ), Column( 'a_id', Integer(), ForeignKey('a.id') ) ) c = Table('c', metadata, Column( 'id', Integer(), primary_key=True ), Column( 'b_id', Integer(), ForeignKey('b.id') ), Column( 'class_id', Integer() ) ) d = Table('d', metadata, Column( 'id', Integer(), primary_key=True ), Column( 'data', Integer() ) mappers mapper( A, a ) mapper( B, b, properties={'a': relationship( A, uselist=False,backref='b', 'c':relationship( C, uselist=False, backref='b') }) # Does a full join, does not work mapper( C, c, polymorphic_on = a.c.type ) mapper( D, d, inherits=C, polymorphic_identity = D ) how can i change c to polymorphic on a, through the relationship? is there a way to sort by d.data? (b-c/d is one-on-one). -- 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...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
Re: [sqlalchemy] Polymorphic on another table?
thx, is there a way to set that up, or something similar? after giving it thought, maybe polymorphic_on isn't what i need. in some sense, table A is similar to a generic container, and i want to constrain the type of C depending on A's type column. is there a way to do this? On Wed, May 5, 2010 at 5:15 PM, Michael Bayer mike...@zzzcomputing.comwrote: On May 5, 2010, at 5:01 PM, Timmy Chan wrote: i have 4 tables, a, b, c, d. a has one-to-many relation with b, b with one-to-one relationship with c, c is a polymorphic on a.type, with d being one of the polymorphic types. is there a way to implement this? details: this is what im trying to do in sqlalchemy: a = Table('a', metadata, Column( 'id', Integer(), primary_key=True ), Column( 'type', UnicodeText() ) ) b = Table('b', metadata, Column( 'id', Integer(), primary_key=True ), Column( 'a_id', Integer(), ForeignKey('a.id') ) ) c = Table('c', metadata, Column( 'id', Integer(), primary_key=True ), Column( 'b_id', Integer(), ForeignKey('b.id') ), Column( 'class_id', Integer() ) ) d = Table('d', metadata, Column( 'id', Integer(), primary_key=True ), Column( 'data', Integer() ) mappers mapper( A, a ) mapper( B, b, properties={'a': relationship( A, uselist=False,backref='b', 'c':relationship( C, uselist=False, backref='b') }) # Does a full join, does not work mapper( C, c, polymorphic_on = a.c.type ) mapper( D, d, inherits=C, polymorphic_identity = D ) how can i change c to polymorphic on a, through the relationship? is there a way to sort by d.data? (b-c/d is one-on-one). this mapping is incorrect. mapper(C) cannot be polymorphic on a table which is not part of its mapping, and mapper(C) does not contain an inherits keyword to that of A. Usually the polymorphic_on setting is on the base-most mapper in the hierarchy and its not clear here which mapper you intend for that to be. -- 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...@googlegroups.comsqlalchemy%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en. -- 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...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
Re: [sqlalchemy] Polymorphic on another table?
C/D objects doesn't exist without A and B? maybe walk up the graph: C.b.a.type im not sure this schema is sensible, if it's really bad, please advise, im not attached to it! thax! On Wed, May 5, 2010 at 5:28 PM, Michael Bayer mike...@zzzcomputing.comwrote: what query do you want to see when you select C and D objects ? On May 5, 2010, at 5:26 PM, Timmy Chan wrote: thx, is there a way to set that up, or something similar? after giving it thought, maybe polymorphic_on isn't what i need. in some sense, table A is similar to a generic container, and i want to constrain the type of C depending on A's type column. is there a way to do this? On Wed, May 5, 2010 at 5:15 PM, Michael Bayer mike...@zzzcomputing.comwrote: On May 5, 2010, at 5:01 PM, Timmy Chan wrote: i have 4 tables, a, b, c, d. a has one-to-many relation with b, b with one-to-one relationship with c, c is a polymorphic on a.type, with d being one of the polymorphic types. is there a way to implement this? details: this is what im trying to do in sqlalchemy: a = Table('a', metadata, Column( 'id', Integer(), primary_key=True ), Column( 'type', UnicodeText() ) ) b = Table('b', metadata, Column( 'id', Integer(), primary_key=True ), Column( 'a_id', Integer(), ForeignKey('a.id') ) ) c = Table('c', metadata, Column( 'id', Integer(), primary_key=True ), Column( 'b_id', Integer(), ForeignKey('b.id') ), Column( 'class_id', Integer() ) ) d = Table('d', metadata, Column( 'id', Integer(), primary_key=True ), Column( 'data', Integer() ) mappers mapper( A, a ) mapper( B, b, properties={'a': relationship( A, uselist=False,backref='b', 'c':relationship( C, uselist=False, backref='b') }) # Does a full join, does not work mapper( C, c, polymorphic_on = a.c.type ) mapper( D, d, inherits=C, polymorphic_identity = D ) how can i change c to polymorphic on a, through the relationship? is there a way to sort by d.data? (b-c/d is one-on-one). this mapping is incorrect. mapper(C) cannot be polymorphic on a table which is not part of its mapping, and mapper(C) does not contain an inherits keyword to that of A. Usually the polymorphic_on setting is on the base-most mapper in the hierarchy and its not clear here which mapper you intend for that to be. -- 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...@googlegroups.comsqlalchemy%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en. -- 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...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en. -- 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...@googlegroups.comsqlalchemy%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en. -- 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...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
Re: [sqlalchemy] Polymorphic on another table?
thx, that is what i am wondering. they are one-to-one, maybe thats good enough for performance. so there's no easy way to do this. On Wed, May 5, 2010 at 5:44 PM, Michael Bayer mike...@zzzcomputing.comwrote: I meant SQL.if you want to do polymorphic_on based on a.type it would at the very least need to issue: SELECT c.*, a.type JOIN b ON c.b_id = b.id JOIN a ON b.a_id=a which is an expensive way to get to where you're going. It can be done of course but not through relation(). On May 5, 2010, at 5:36 PM, Timmy Chan wrote: C/D objects doesn't exist without A and B? maybe walk up the graph: C.b.a.type im not sure this schema is sensible, if it's really bad, please advise, im not attached to it! thax! On Wed, May 5, 2010 at 5:28 PM, Michael Bayer mike...@zzzcomputing.comwrote: what query do you want to see when you select C and D objects ? On May 5, 2010, at 5:26 PM, Timmy Chan wrote: thx, is there a way to set that up, or something similar? after giving it thought, maybe polymorphic_on isn't what i need. in some sense, table A is similar to a generic container, and i want to constrain the type of C depending on A's type column. is there a way to do this? On Wed, May 5, 2010 at 5:15 PM, Michael Bayer mike...@zzzcomputing.comwrote: On May 5, 2010, at 5:01 PM, Timmy Chan wrote: i have 4 tables, a, b, c, d. a has one-to-many relation with b, b with one-to-one relationship with c, c is a polymorphic on a.type, with d being one of the polymorphic types. is there a way to implement this? details: this is what im trying to do in sqlalchemy: a = Table('a', metadata, Column( 'id', Integer(), primary_key=True ), Column( 'type', UnicodeText() ) ) b = Table('b', metadata, Column( 'id', Integer(), primary_key=True ), Column( 'a_id', Integer(), ForeignKey('a.id') ) ) c = Table('c', metadata, Column( 'id', Integer(), primary_key=True ), Column( 'b_id', Integer(), ForeignKey('b.id') ), Column( 'class_id', Integer() ) ) d = Table('d', metadata, Column( 'id', Integer(), primary_key=True ), Column( 'data', Integer() ) mappers mapper( A, a ) mapper( B, b, properties={'a': relationship( A, uselist=False,backref='b', 'c':relationship( C, uselist=False, backref='b') }) # Does a full join, does not work mapper( C, c, polymorphic_on = a.c.type ) mapper( D, d, inherits=C, polymorphic_identity = D ) how can i change c to polymorphic on a, through the relationship? is there a way to sort by d.data? (b-c/d is one-on-one). this mapping is incorrect. mapper(C) cannot be polymorphic on a table which is not part of its mapping, and mapper(C) does not contain an inherits keyword to that of A. Usually the polymorphic_on setting is on the base-most mapper in the hierarchy and its not clear here which mapper you intend for that to be. -- 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...@googlegroups.comsqlalchemy%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en. -- 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...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en. -- 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...@googlegroups.comsqlalchemy%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en. -- 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...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en. -- 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...@googlegroups.comsqlalchemy%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post
[sqlalchemy] Best way to order by columns in relationships?
i have a few polymorphic tables, and i want to sort by a column in one of the relationship. i have tables a,b,c,d, with relationship a to b, b to c, c to d. a to b is one-to-many b to c and c to d are one-to-one, but polymorphic. given an item in table a, i will have a list of items b, c, d (all one to one). how do i use sqlalchemy to sort them by a column in table d? what i want is the sql statement: select * from b inner join c on b.c_key = c.b_key inner join d on c.d_key = d.c_key where b.a_key = ? order by d.sort_key in sqlalchemy. it does not have to be on one query, as c and d are polymorphic tables. i have relationships on each of a, b, c, d. but as c and d are polymorphic tables (on b), so i cannot hard code it. -- 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...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.