[sqlalchemy] Re: Cascade Deletes
Thank you for your response. In that case, how do you manage these kinds of situations in SQLite and other engines in MySQL? Do you manually delete the children as well? On Jul 28, 10:35 am, Stefano Fontanelli s.fontane...@asidev.com wrote: Il 28/07/11 01.15, Aviv Giladi ha scritto: Hi, I am actually using both MySQL and SQLite (one on the dev machine, one on the server). Does that make a difference? ONDELETE and ONUPDATE don't work on SQLite and MySQL MyISAM. You must change your database to test them. In MySQL you can create your database and tables as InnoDB. Regards, Stefano. -- 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 sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
Re: [sqlalchemy] Re: Cascade Deletes
SQLAlchemy's cascade='all, delete-orphan' implements the same CASCADE functionality as ONDELETE does, in Python. It is just less efficient since collections need to be fully loaded into memory for them to be processed. On Jul 30, 2011, at 1:49 PM, Aviv Giladi wrote: Thank you for your response. In that case, how do you manage these kinds of situations in SQLite and other engines in MySQL? Do you manually delete the children as well? On Jul 28, 10:35 am, Stefano Fontanelli s.fontane...@asidev.com wrote: Il 28/07/11 01.15, Aviv Giladi ha scritto: Hi, I am actually using both MySQL and SQLite (one on the dev machine, one on the server). Does that make a difference? ONDELETE and ONUPDATE don't work on SQLite and MySQL MyISAM. You must change your database to test them. In MySQL you can create your database and tables as InnoDB. Regards, Stefano. -- 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 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 sqlalchemy@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] update existing row
hi, can't figure out why raw SQL works fine, but update() is not working: 1.working raw SQL: self.session.execute(update public.my_table set status='L',updated_at=now() where my_name='%s' % (self.my_name)) 2.non working update() from Alchemy: s = aliased(MyTable) query = self.session.query(s).filter(s.my_name==self.my_name) sts = self.session.execute(query).fetchone() sts.update(values={'status':'L'}) sts.update(values={s.status:'L'}) File /usr/lib/python2.6/dist-packages/sqlalchemy/engine/base.py, line 2097, in _key_fallback Could not locate column in row for column '%s' % key) sqlalchemy.exc.NoSuchColumnError: Could not locate column in row for column 'update' But Column s.status exists ... appreciate any help, --vs -- 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 sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] Re: Cascade Deletes
Sorry, but I am really confused. Are you guys saying that on SQLite for example, cascade deletes don't work at all? Or do they work, but are less efficient? Thanks again! On Jul 30, 11:08 am, Michael Bayer mike...@zzzcomputing.com wrote: SQLAlchemy's cascade='all, delete-orphan' implements the same CASCADE functionality as ONDELETE does, in Python. It is just less efficient since collections need to be fully loaded into memory for them to be processed. On Jul 30, 2011, at 1:49 PM, Aviv Giladi wrote: Thank you for your response. In that case, how do you manage these kinds of situations in SQLite and other engines in MySQL? Do you manually delete the children as well? On Jul 28, 10:35 am, Stefano Fontanelli s.fontane...@asidev.com wrote: Il 28/07/11 01.15, Aviv Giladi ha scritto: Hi, I am actually using both MySQL and SQLite (one on the dev machine, one on the server). Does that make a difference? ONDELETE and ONUPDATE don't work on SQLite and MySQL MyISAM. You must change your database to test them. In MySQL you can create your database and tables as InnoDB. Regards, Stefano. -- 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 sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group athttp://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 sqlalchemy@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] Re: update existing row
Maybe someone can just place an example of correct update() usage please: can't sort it out from docs rather google, thanks. On Jul 30, 3:51 pm, vitsin vitaly.sinit...@gmail.com wrote: hi, can't figure out why raw SQL works fine, but update() is not working: 1.working raw SQL: self.session.execute(update public.my_table set status='L',updated_at=now() where my_name='%s' % (self.my_name)) 2.non working update() from Alchemy: s = aliased(MyTable) query = self.session.query(s).filter(s.my_name==self.my_name) sts = self.session.execute(query).fetchone() sts.update(values={'status':'L'}) sts.update(values={s.status:'L'}) File /usr/lib/python2.6/dist-packages/sqlalchemy/engine/base.py, line 2097, in _key_fallback Could not locate column in row for column '%s' % key) sqlalchemy.exc.NoSuchColumnError: Could not locate column in row for column 'update' But Column s.status exists ... appreciate any help, --vs -- 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 sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.