RE: [sqlalchemy] Cannot retrieve PostgreSQL array column with session.query() : TypeError: unhashable type: 'list'

2010-10-14 Thread Julien Demoor
Thanks for your reply. What you propose would work for me, but in the meantime I need a workaround. I thought of serializing the arrays in SQL, then converting back to tuples in my code, but the objects contained in the arrays are quite complex to parse (decimals, datetims...). So I tried

[sqlalchemy] Re: MapperExtension.[before|after]_update problem

2010-10-14 Thread Christophe de Vienne
Hi Connor, On 13 oct, 18:23, Conor conor.edward.da...@gmail.com wrote: On 10/13/2010 10:55 AM, Christophe de Vienne wrote: Hi all, I am running into an issue with MapperExtension.[before|after]_update. [...] AFAIK SQLAlchemy does not support the following in MapperExtensions:

Re: [sqlalchemy] Dynamic query

2010-10-14 Thread Julien Cigar
Given all this magic with .with_polymorphic(), I'm now wondering if it's really worth to have a new Query class (by subclassing orm.Query) per mapped object just to apply some filters... At first I found quite elegant to have one Query object per mapped class, but now I'm wondering if it's

Re: [sqlalchemy] Cannot retrieve PostgreSQL array column with session.query() : TypeError: unhashable type: 'list'

2010-10-14 Thread Michael Bayer
On Oct 14, 2010, at 4:38 AM, Julien Demoor wrote: Thanks for your reply. What you propose would work for me, but in the meantime I need a workaround. If you need that exact pattern to work, build a TypeDecorator around ARRAY and have it return a tuple around the result. TypeDecorator is

Re: [sqlalchemy] Dynamic query

2010-10-14 Thread Michael Bayer
On Oct 14, 2010, at 9:28 AM, Julien Cigar wrote: Given all this magic with .with_polymorphic(), I'm now wondering if it's really worth to have a new Query class (by subclassing orm.Query) per mapped object just to apply some filters... At first I found quite elegant to have one Query

Re: [sqlalchemy] Checking the availablity of a booked Item

2010-10-14 Thread chaouche yacine
Here's the SQL I got : SELECT face.id AS face_id FROM face LEFT OUTER JOIN face_bookings__booking_faces AS face_bookings__booking_faces_1        ON face.id = face_bookings__booking_faces_1.face_id LEFT OUTER JOIN booking        ON booking.id =

Re: [sqlalchemy] Checking the availablity of a booked Item

2010-10-14 Thread chaouche yacine
Here's the SQL I got : SELECT face.id AS face_id FROM face LEFT OUTER JOIN face_bookings__booking_faces AS face_bookings__booking_faces_1        ON face.id = face_bookings__booking_faces_1.face_id LEFT OUTER JOIN booking        ON booking.id =

[sqlalchemy] Subtransactions problem

2010-10-14 Thread Juan Antonio Ibáñez
Hello! I am dealing with Turbogears and SQL Alchemy. I need to make one import from a CSV file to a MySQL DB. I need also to controll which rows fails on import. I am working with the next code inside a loop: try: session.begin(subtransactions=True)

Re: [sqlalchemy] Checking the availablity of a booked Item

2010-10-14 Thread Thadeus Burgess
http://www.sqlalchemy.org/docs/reference/orm/query.html#sqlalchemy.orm.join isouter = True -- Thadeus On Thu, Oct 14, 2010 at 10:26 AM, chaouche yacine yacinechaou...@yahoo.comwrote: Here's the SQL I got : SELECT face.id AS face_id FROM face LEFT OUTER JOIN face_bookings__booking_faces

Re: [sqlalchemy] Subtransactions problem

2010-10-14 Thread Michael Bayer
On Oct 14, 2010, at 11:40 AM, Juan Antonio Ibáñez wrote: Hello! I am dealing with Turbogears and SQL Alchemy. I need to make one import from a CSV file to a MySQL DB. I need also to controll which rows fails on import. I am working with the next code inside a loop:

RE: [sqlalchemy] Cannot retrieve PostgreSQL array column with session.query() : TypeError: unhashable type: 'list'

2010-10-14 Thread Julien Demoor
Thanks again for your help. I had tried using TypeDecorator without success. Now I tested further and found the problem is more narrow in scope than I thought. If I create a table MyTable that contains a column MyArray, with MyArray a TypeDecorator subclass that converts lists to tuples, insert a

Re: [sqlalchemy] Very strange behaviour in SqlAlchemy (maybe a bug)

2010-10-14 Thread Michael Bayer
On Oct 13, 2010, at 10:48 AM, Christian Démolis wrote: Hi, q = model.session.query( # model.Collaborateur.LesIns.any(model.or_(model.Instruction.FinValiditetime.time(), model.Instruction.FinValidite==None)), model.Collaborateur.Fonction ) q = q.limit(5) print str(q) for e in

Re: [sqlalchemy] Cannot retrieve PostgreSQL array column with session.query() : TypeError: unhashable type: 'list'

2010-10-14 Thread Michael Bayer
On Oct 14, 2010, at 11:53 AM, Julien Demoor wrote: Thanks again for your help. I had tried using TypeDecorator without success. Now I tested further and found the problem is more narrow in scope than I thought. If I create a table MyTable that contains a column MyArray, with MyArray a

Re: [sqlalchemy] getting floats instead of decimals from session.execute

2010-10-14 Thread Michael Bayer
On Oct 13, 2010, at 8:04 PM, Chris Withers wrote: On 13/10/2010 22:37, Michael Bayer wrote: use text() with Numeric(as_decimal=False) I can't quite join the dots on this one... I get passed a bunch of sql to execute, I don't have control over that. Where do I wire in

RE: [sqlalchemy] Cannot retrieve PostgreSQL array column with session.query() : TypeError: unhashable type: 'list'

2010-10-14 Thread Julien Demoor
Thank you very much! -Message d'origine- De : sqlalchemy@googlegroups.com [mailto:sqlalch...@googlegroups.com] De la part de Michael Bayer Envoyé : jeudi 14 octobre 2010 18:08 À : sqlalchemy@googlegroups.com Objet : Re: [sqlalchemy] Cannot retrieve PostgreSQL array column with

Re: [sqlalchemy] getting floats instead of decimals from session.execute

2010-10-14 Thread Chris Withers
On 14/10/2010 17:10, Michael Bayer wrote: I get passed a bunch of sql to execute, I don't have control over that. Where do I wire in Numeric(as_decimal=False) and how do I tell where I need to given an arbitrary select as a string of sql? text() is in the docs, including an example of

Re: [sqlalchemy] getting floats instead of decimals from session.execute

2010-10-14 Thread Michael Bayer
On Oct 14, 2010, at 1:35 PM, Chris Withers wrote: On 14/10/2010 17:10, Michael Bayer wrote: I get passed a bunch of sql to execute, I don't have control over that. Where do I wire in Numeric(as_decimal=False) and how do I tell where I need to given an arbitrary select as a string of sql?

[sqlalchemy] efficiently setting many to many collections when I have a sequence of ids.

2010-10-14 Thread Chris Withers
Hi All, I currently have code that looks like this: recipients = [] if recipient_ids: for id in recipient_ids.split(','): recipients.append( session.query(recipient.Recipient).filter_by(id=id).one() ) else: recipient_ids = () feed.recipients = recipients Where the

[sqlalchemy] Polyphormic class insertion by SA .vs. by database triggers

2010-10-14 Thread Cleber Rodrigues
Hi list, I've a sample application that makes use of polymorphism both with and without SQLAlchemy. On the non-SA side, I've implemented record insertion via stored procedures. Now, integrating new code based on SA, the ORM behaviour is to create both the base and the inherited record. SA fails

Re: [sqlalchemy] efficiently setting many to many collections when I have a sequence of ids.

2010-10-14 Thread Conor
On 10/14/2010 01:30 PM, Chris Withers wrote: Hi All, I currently have code that looks like this: recipients = [] if recipient_ids: for id in recipient_ids.split(','): recipients.append( session.query(recipient.Recipient).filter_by(id=id).one() ) else:

Re: [sqlalchemy] Polyphormic class insertion by SA .vs. by database triggers

2010-10-14 Thread Michael Bayer
On Oct 14, 2010, at 4:25 PM, Cleber Rodrigues wrote: Hi list, I've a sample application that makes use of polymorphism both with and without SQLAlchemy. On the non-SA side, I've implemented record insertion via stored procedures. Now, integrating new code based on SA, the ORM

Re: [sqlalchemy] Error - class 'sqlalchemy.exc.OperationalError': (OperationalError) (2006, 'MySQL server has gone away')

2010-10-14 Thread Warwick Prince
HiTimmy What OS are you running under for each? Cheers Warwick Warwick Prince Managing Director mobile: +61 411 026 992 skype: warwickprince phone: +61 7 3102 3730 fax: +61 7 3319 6734 web: www.mushroomsys.com On 15/10/2010, at 7:48 AM, Timmy Chan wrote: sorry if this is

[sqlalchemy] Error - class 'sqlalchemy.exc.OperationalError': (OperationalError) (2006, 'MySQL server has gone away')

2010-10-14 Thread Timmy Chan
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

Re: [sqlalchemy] Error - class 'sqlalchemy.exc.OperationalError': (OperationalError) (2006, 'MySQL server has gone away')

2010-10-14 Thread Timmy Chan
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

[sqlalchemy] Re: Error - class 'sqlalchemy.exc.OperationalError': (OperationalError) (2006, 'MySQL server has gone away')

2010-10-14 Thread Lloyd Kvam
On Oct 14, 5:48 pm, Timmy Chan timmy.cha...@gmail.com 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,