Re: [sqlalchemy] set a query timeout on a per query basis

2018-11-13 Thread Mike Bayer
you can set that then with before_cursor_execute() and then reset it on after_cursor_execute(). On Tue, Nov 13, 2018 at 12:44 PM Jonathan Vanasco wrote: > > In postgres, you can execute: > > SET statement_timeout = 6; > > at any point. It lasts until the end of the "session", which I

Re: [sqlalchemy] set a query timeout on a per query basis

2018-11-13 Thread Jonathan Vanasco
In postgres, you can execute: SET statement_timeout = 6; at any point. It lasts until the end of the "session", which I believe would be the SqlAlchemy connection's lifetime. On Monday, November 12, 2018 at 6:44:06 PM UTC-5, Mike Bayer wrote: > > > if statement_timeout is accepted

Re: [sqlalchemy] set a query timeout on a per query basis

2018-11-12 Thread Mike Bayer
On Mon, Nov 12, 2018 at 6:12 PM Brian Cherinka wrote: > > Hmm. Ok. I'm using a postgres database with the psycopg2 driver. I'm aware > of the `statement_timeout` option in `postgres` which I can pass into the > psycopg2 `connect` method. As far as I can tell there's not a way to pass > that

Re: [sqlalchemy] set a query timeout on a per query basis

2018-11-12 Thread Brian Cherinka
Hmm. Ok. I'm using a postgres database with the psycopg2 driver. I'm aware of the `statement_timeout` option in `postgres` which I can pass into the psycopg2 `connect` method. As far as I can tell there's not a way to pass that keyword in through SQLAlchemy after the db engine has been

Re: [sqlalchemy] set a query timeout on a per query basis

2018-11-12 Thread Mike Bayer
On Mon, Nov 12, 2018 at 2:08 PM Brian Cherinka wrote: > > What's the best way to set a timeout for specific queries? I have a custom > query tool that uses SQLAlchemy to build and submit queries. This tool can > be used in a local python session with a database. I'm also using it to > allow

[sqlalchemy] set a query timeout on a per query basis

2018-11-12 Thread Brian Cherinka
What's the best way to set a timeout for specific queries? I have a custom query tool that uses SQLAlchemy to build and submit queries. This tool can be used in a local python session with a database. I'm also using it to allow queries in a Flask web-app. In general, I do not want to apply a