Re: [sqlalchemy] Too slow commit?

2016-03-22 Thread Jonathan Vanasco
Yes, the approach would be to use the exact same session: dbSession = SQLSession.sql_session() functionA() functionB() dbSession.close() It looks like functionA and functionB each call `SQLSession.sql_session()`, which will cause problems. I believe that will create

Re: [sqlalchemy] Too slow commit?

2016-03-22 Thread TomS.
Thank you for your answer! Function B is called after A. Literally: / //functionA()// //functionB()/ It works fine when at the end of A /inserting_session.close_all()/ is called, but it is not very elegant (moreover it probably causes "MySQL server has gone away", but this is a different

Re: [sqlalchemy] Too slow commit?

2016-03-22 Thread Simon King
It sounds like the transaction for task B is starting before A's transaction has been committed, but you haven't really given enough information to debug further. How are you managing your sessions and transactions? Do B and A actually overlap (ie. does B start before A finishes)? Simon On Tue,

[sqlalchemy] Too slow commit?

2016-03-22 Thread TomS.
Could you advise what would be the best approach for the following problem. I have Flask-Celery task. Task consists of two functions (both are run in the same one Celery task): A and B. Function A calculates values which are then used by B function. Values are stored in DB (via SQLAlchemy).

Re: [sqlalchemy] Re: rowset generating functions in FROM clause

2016-03-22 Thread Mike Bayer
On 03/22/2016 05:37 AM, Andy S wrote: I'm stuck with the need to generate a query of the form like: | SELECT a.id, b.name, jr.* FROM a,b outer join jsonb_populate_recordset(b.jrs)asjr(bid numeric,name varchar)on (TRUE) WHERE a.id =b.a_id

Re: [sqlalchemy] Re: order by child object's field

2016-03-22 Thread Simon King
For what it's worth, SQLAlchemy usually does add the join condition for you, based on your relationship definitions. But the second parameter to query.join() is an optional expression that *replaces* the join condition that would normally be generated. Simon On Mon, Mar 21, 2016 at 5:42 PM,

[sqlalchemy] Re: rowset generating functions in FROM clause

2016-03-22 Thread Andy S
Also, I still can pass a string 'j.goods_id' to query() call this fixes the first error but then PG query compiler says it can't find a RECORD definition for the jsonb_ function call that is required according to it's API. I think that's because of double-quoting of the alias'ed expression in

[sqlalchemy] Re: rowset generating functions in FROM clause

2016-03-22 Thread Andy S
Made this way as I've understood the linked PR: class ColumnFunction(functions.FunctionElement): __visit_name__ = 'function' @property def columns(self): return FromClause.columns.fget(self) def _populate_column_collection(self): for col in self.column_defs: