[sqlalchemy] MySQL server has gone away

2014-03-18 Thread Ni Wesley
Hi all, I hit a problem when using sqlalchemy operates mysql. Engine.execute hangs about 5 mins... and then, get error: 'MySQL server has gone away' or 'Lost connection to MySQL server during query'. Actually, when operation hangs, I login mysql server is OK. Why this happened? Or how to

[sqlalchemy] AssertionError

2014-03-18 Thread lars van gemerden
Hi all, Does anyone know hoe to interpret the following error? AssertionError: A conflicting state is already present in the identity map for key (class 'models.data.database.Keuze', (1,)) Cheers, Lars -- You received this message because you are subscribed to the Google Groups

Re: [sqlalchemy] Unique Many-to-Many

2014-03-18 Thread Morgan McClure
Yeah I confirmed set collections don't actually fix it, I guess setting a rollback point is required. Is there any chance this is a difference between the way mysql does table locking and postgres? The collections in question have lazy=dynamic set so I'm wondering if previously it wasn't a

Re: [sqlalchemy] AssertionError

2014-03-18 Thread Michael Bayer
it means this: a1 = A(id=1) session.add(a1) session.commit() a2 = A(id=1) session.add(a2) # -- error On Mar 18, 2014, at 9:59 AM, lars van gemerden l...@rational-it.com wrote: Hi all, Does anyone know hoe to interpret the following error? AssertionError: A conflicting state is

Re: [sqlalchemy] Unique Many-to-Many

2014-03-18 Thread Michael Bayer
On Mar 18, 2014, at 11:30 AM, Morgan McClure mcclure.mor...@gmail.com wrote: Yeah I confirmed set collections don't actually fix it, I guess setting a rollback point is required. Is there any chance this is a difference between the way mysql does table locking and postgres? The

[sqlalchemy] MySQL server has gone away

2014-03-18 Thread Jameson Lee
Your connection to the database has been idle for too long and MySQL has disconnected it. You can mitigate it by having fake traffic that will use the connection. Increasing the timeout of MySQL. Set SQLAlchemy to recycle connections in the connection pool more aggressively (and make sure

[sqlalchemy] Re: MySQL server has gone away

2014-03-18 Thread Ni Wesley
I tried all you said. Here is my code: engine = create_engine(db_url, pool_size=100,max_overflow=150,echo=engine_echo,pool_recycle=3600) And, in the beginning, I googled a lot and add this: def _ping_db(): #session.execute('show variables') try: session.execute('select 1')