[sqlalchemy] Optimize SQLAlchemy query

2017-06-30 Thread mvidalgarcia
Hi, I'm performing a query to some data models but the ORM response time looks much higher compared to the SQL one. I have a script to reproduce the problem here . Currently getting values like sql time: 0.068972826004 >

Re: [sqlalchemy] Optimize SQLAlchemy query

2017-06-30 Thread Mike Bayer
On Fri, Jun 30, 2017 at 8:56 AM, Simon King wrote: > Your "sql time" measurement only includes the time it takes to send > the query to the database. I don't think it includes the time that the > database has to evaluate the query and return the rows. To measure > that,

Re: [sqlalchemy] Optimize SQLAlchemy query

2017-06-30 Thread Simon King
On Fri, Jun 30, 2017 at 12:44 PM, mvidalgarcia wrote: > Hi, I'm performing a query to some data models but the ORM response time > looks much higher compared to the SQL one. I have a script to reproduce the > problem here. > Currently getting values like > >> sql time:

[sqlalchemy] Understanding sporadic ObjectDeletedError (in gevent)

2017-06-30 Thread Anders Steinlein
Hi, We're using SQLAlchemy (see below for versions) on Flask running on uWSGI in gevent mode, with psycopg2 to PostgreSQL 9.4. We recently switched from regular prefork+threaded to gevent mode, and with it applied all gevent monkey patches and the psycogreen package for the psycopg2 gevent wait

Re: [sqlalchemy] Understanding sporadic ObjectDeletedError (in gevent)

2017-06-30 Thread Anders Steinlein
On Fri, Jun 30, 2017 at 8:04 PM, Mike Bayer wrote: > On Fri, Jun 30, 2017 at 11:52 AM, Anders Steinlein wrote: > > [...] > > > > > I've set _use_threadlocal = True on the connection pool, as my thinking > > initially was that we could be getting a

[sqlalchemy] quote=False for all columns in table

2017-06-30 Thread Seth P
Is there a way (when using declarative) to specify that all the columns of a table should use quote=False without specifying it explicitly for each column? I've tried setting __table_args__ = { 'quote_schema': False, 'quote': False }, but that just affects the schema and table name, not the

Re: [sqlalchemy] Understanding sporadic ObjectDeletedError (in gevent)

2017-06-30 Thread Mike Bayer
On Fri, Jun 30, 2017 at 3:48 PM, Anders Steinlein wrote: > I see, and that makes sense. However, wouldn't that be true in regular > threaded environments as well? Any idea why this is manifesting itself after > we switched to gevent? Simply the fact that we're now more likely to

Re: [sqlalchemy] quote=False for all columns in table

2017-06-30 Thread Mike Bayer
On Fri, Jun 30, 2017 at 4:31 PM, Seth P wrote: > Is there a way (when using declarative) to specify that all the columns of a > table should use quote=False without specifying it explicitly for each > column? Easiest is just to call your own my_column(...) function that sets

Re: [sqlalchemy] quote=False for all columns in table

2017-06-30 Thread Seth P
I'm just accessing a vendor-provided Oracle database. The database itself is all upper(lower?) case (I'm new to Oracle), whereas I want my declarative model columns to be camelCase (and the emitted SQL to be unquoted camelCase) to match the vendor's documentation. I could make the column names

Re: [sqlalchemy] Understanding sporadic ObjectDeletedError (in gevent)

2017-06-30 Thread Mike Bayer
On Fri, Jun 30, 2017 at 11:52 AM, Anders Steinlein wrote: > After this switch, we're seeing sporadic ObjectDeletedError exceptions > illustrated by the following simple lines of code: > > @newsletters.route('/create/', methods=['GET', 'POST']) > @login_required > def

Re: [sqlalchemy] quote=False for all columns in table

2017-06-30 Thread Mike Bayer
On Fri, Jun 30, 2017 at 5:10 PM, Seth P wrote: > I'm just accessing a vendor-provided Oracle database. The database itself is > all upper(lower?) case (I'm new to Oracle), case insensitive if unquoted names are used. whereas I want my declarative > model columns to be