[sqlalchemy] Exception catching, rollback clarification

2011-02-25 Thread Romy
Hey Michael, Just had a MySQL has gone away that I intentionally triggered by setting the pool recycle to be higher than wait_timeout. Afterwards, I watched the commit() at the end of the request throw a Can't reconnect until invalid transaction is rolled back, which the catch block was handling

[sqlalchemy] Re: Unable to create a view that has where condition

2011-02-25 Thread bool
Shouldn't these formats be handled properly? Or am I missing something? I think this is a limitation of sqlite if I am not wrong... -- 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.

[sqlalchemy] cascading deletes

2011-02-25 Thread Chris Withers
Hi All, I have the following models: class IP(Base): __tablename__ = 'ip' username = Column(String(50), ForeignKey('user.username'), primary_key=True) ip = Column(String(15), primary_key=True, index=True) class User(Base):

[sqlalchemy] LIKE operator and double percent signs

2011-02-25 Thread Jon Nelson
I've been wondering something about sqlalchemy - let's say I have a text column foo. Being able to do foo.startswith(some_value), foo.endswith, foo.like and so on is really nice. However, I've noticed that the SQL that is emitted contains two percent signs. However, I thought only one was

Re: [sqlalchemy] Re: Unable to create a view that has where condition

2011-02-25 Thread Michael Bayer
to get correct results. Shouldn't these formats be handled properly? Or am I missing something? === [20110225 11:09:11:127 base.py:945 INFO] PRAGMA table_info(y) [20110225 11:09:11

Re: [sqlalchemy] Exception catching, rollback clarification

2011-02-25 Thread Michael Bayer
if your application is in some kind of loop that wants a single Session to recover after an exception, part of that loop's construction should ensure exceptions are handled appropriately. and the session's state is reset. Like the docs mention, this is trivial for web applications, all of

Re: [sqlalchemy] LIKE operator and double percent signs

2011-02-25 Thread Michael Bayer
% is significant in DBAPIs like postgresql and mysqldb where pyformat and format: %(foo)s and %s, are allowed, so % must be doubled. On Feb 25, 2011, at 8:53 AM, Jon Nelson wrote: I've been wondering something about sqlalchemy - let's say I have a text column foo. Being able to do

Re: [sqlalchemy] cascading deletes

2011-02-25 Thread Michael Bayer
On Feb 25, 2011, at 7:31 AM, Chris Withers wrote: Hi All, I have the following models: class IP(Base): __tablename__ = 'ip' username = Column(String(50), ForeignKey('user.username'), primary_key=True) ip = Column(String(15),

Re: [sqlalchemy] LIKE operator and double percent signs

2011-02-25 Thread Jon Nelson
On Fri, Feb 25, 2011 at 9:15 AM, Michael Bayer mike...@zzzcomputing.com wrote: % is significant in DBAPIs like postgresql and mysqldb where pyformat and format:  %(foo)s and %s, are allowed, so % must be doubled. So does psycopg2 send '%' or '%%' ? It seems to me that if the strings are held

Re: [sqlalchemy] LIKE operator and double percent signs

2011-02-25 Thread Michael Bayer
On Feb 25, 2011, at 10:20 AM, Jon Nelson wrote: On Fri, Feb 25, 2011 at 9:15 AM, Michael Bayer mike...@zzzcomputing.com wrote: % is significant in DBAPIs like postgresql and mysqldb where pyformat and format: %(foo)s and %s, are allowed, so % must be doubled. So does psycopg2 send

[sqlalchemy] Re: cascading deletes

2011-02-25 Thread Eric Ongerth
Wouldn't he need to configure the ondelete cascade for even session.delete(session.query(User).get('testname')) to work that way? I know why the cascade is necessary for session.query(User).delete() to also delete the associated IP instances. But I don't quite get why it's not necessary for

Re: [sqlalchemy] Re: cascading deletes

2011-02-25 Thread Michael Bayer
SQLAlchemy cascades deletes to collections associated with objects that are present in the Session. Not every database supports cascading of foreign keys. I didn't introduce this concept in my last email, but if you configure foreign key level cascades, and your application is only to be

[sqlalchemy] auto-flush not flushing, cascade misbehaving

2011-02-25 Thread Chris Withers
Hi All, With these models: class User(Base): __tablename__ = 'user' __table_args__ = {'mysql_engine':'InnoDB'} username = Column(String(50), primary_key=True) grants = dynamic_loader(Grant) class Grant(Base): __tablename__ = 'grant' __table_args__ =

Re: [sqlalchemy] auto-flush not flushing, cascade misbehaving

2011-02-25 Thread Michael Bayer
On Feb 25, 2011, at 11:59 AM, Chris Withers wrote: Hi All, With these models: class User(Base): __tablename__ = 'user' __table_args__ = {'mysql_engine':'InnoDB'} username = Column(String(50), primary_key=True) grants = dynamic_loader(Grant) class Grant(Base):