[sqlalchemy] Re: Additions to model not getting flushed to DB?? (Pylons)
Doh, I should have turned on the SQL echo. Now that I have, it's even more puzzling to me. It shows the 'contact' being inserted and committed -- but it never appears in MySQL! 2006-12-23 17:33:15,140 INFO sqlalchemy.engine.base.Engine.0x..cc BEGIN 2006-12-23 17:33:15,145 INFO sqlalchemy.engine.base.Engine.0x..cc SELECT current_timestamp 2006-12-23 17:33:15,145 INFO sqlalchemy.engine.base.Engine.0x..cc [] 2006-12-23 17:33:15,150 INFO sqlalchemy.engine.base.Engine.0x..cc INSERT INTO contact (client_id, email, password, firstname, lastname, ts_created, ts_updated) VALUES (%s, %s, %s, %s, %s, %s, %s) 2006-12-23 17:33:15,150 INFO sqlalchemy.engine.base.Engine.0x..cc [9L, '[EMAIL PROTECTED]', None, None, None, datetime.datetime(2006, 12, 23, 17, 33, 44), None] 2006-12-23 17:33:15,158 INFO sqlalchemy.engine.base.Engine.0x..cc COMMIT #vendor.upload Query contacts after flush=[] If I switch my Pylons development.ini to use an SQLite DB, the app works as expected until I get to the same flush(): contact = model.Contact(client_id=client.client_id, email=row['contactemail'], password=row.get('contactpassword'), firstname=row.get('contactfirstname'), lastname=row.get('contactlastname')) self.session.save(contact) self.session.flush() The Pylons traceback reports: self.session.flush() ... sqlalchemy.exceptions.SQLError: (OperationalError) SQL logic error or missing database 'INSERT INTO contact (client_id, email, password, firstname, lastname, ts_created, ts_updated) VALUES (?, ?, ?, ?, ?, ?, ?)' [1, '[EMAIL PROTECTED]', None, None, None, '2006-12-24 00:25:35', None] The SQL echo looks good, until the ROLLBACK: 2006-12-23 19:25:35,874 INFO sqlalchemy.engine.base.Engine.0x..0c BEGIN 2006-12-23 19:25:35,878 INFO sqlalchemy.engine.base.Engine.0x..0c SELECT current_timestamp 2006-12-23 19:25:35,878 INFO sqlalchemy.engine.base.Engine.0x..0c [] 2006-12-23 19:25:35,879 INFO sqlalchemy.engine.base.Engine.0x..0c INSERT INTO contact (client_id, email, password, firstname, lastname, ts_created, ts_updated) VALUES (?, ?, ?, ?, ?, ?, ?) 2006-12-23 19:25:36,031 INFO sqlalchemy.engine.base.Engine.0x..0c [1, '[EMAIL PROTECTED]', None, None, None, '2006-12-24 00:25:35', None] 2006-12-23 19:25:36,086 INFO sqlalchemy.engine.base.Engine.0x..0c ROLLBACK That self.session is created with a Pylons __before__ method: def __before__(self): self.session = session_context.current self.q = self.session.query(model.Vendor) and other methods use this just fine as far as I can tell. How can I track down whether there's a missing database or what the SQL logic error might be? Thanks. --~--~-~--~~~---~--~~ 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 unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: Additions to model not getting flushed to DB?? (Pylons)
seems like Pylons is not properly maintaining the session within requests. unless there is some way you can reproduce this problem without any dependencies on pylons ? is this using the newest SA/Pylons code that Ben was recently working on ? --~--~-~--~~~---~--~~ 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 unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: Additions to model not getting flushed to DB?? (Pylons)
Michael Bayer [EMAIL PROTECTED] writes: seems like Pylons is not properly maintaining the session within requests. Yeah, it sure feels like that. :-( unless there is some way you can reproduce this problem without any dependencies on pylons ? is this using the newest SA/Pylons code that Ben was recently working on ? Hrmmm, I'm not sure ... I am not on the bleeding edge with nightly easy_install -U *=dev :-) I'll see if I can reproduce in a small scale in Pylons; if so, I'll try reproducing in standalone SA. Thanks for the pointers. --~--~-~--~~~---~--~~ 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 unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: Additions to model not getting flushed to DB?? (Pylons)
On Dec 23, 2006, at 8:56 PM, Chris Shenton wrote: Michael Bayer [EMAIL PROTECTED] writes: seems like Pylons is not properly maintaining the session within requests. Yeah, it sure feels like that. :-( unless there is some way you can reproduce this problem without any dependencies on pylons ? is this using the newest SA/Pylons code that Ben was recently working on ? Hrmmm, I'm not sure ... I am not on the bleeding edge with nightly easy_install -U *=dev :-) Pylons trunk (dev) provides a session_context out of the box, but the 0.9.3 release (which it sounds like you're using) does not. Showing how your session_context variable is created might be helpful. I saw a prompt in your last email: self.session.flush() Are you using paster shell, or the interactive debugger? Otherwise nothing looks out of the ordinary minus the fact you're not seeing your data. Obvious question: are you seeing the changes made to the database after the commit? -- Philip Jenvey --~--~-~--~~~---~--~~ 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 unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---