Re: [sqlalchemy] prepared statements

2014-02-06 Thread Michael Bayer
On Feb 6, 2014, at 12:34 PM, Rick Otten rottenwindf...@gmail.com wrote: Hello, I'm using SQLAlchemy 0.8.4 with PostgreSQL 9.3. I have a situation where I need to run the same set of queries millions of times in one session. I think it would be very helpful from a performance

Re: [sqlalchemy] prepared statements

2014-02-06 Thread Michael Bayer
On Feb 6, 2014, at 12:34 PM, Rick Otten rottenwindf...@gmail.com wrote: Hello, I'm using SQLAlchemy 0.8.4 with PostgreSQL 9.3. I have a situation where I need to run the same set of queries millions of times in one session. After sending that, I just read the words “same set of queries

Re: [sqlalchemy] prepared statements

2014-02-06 Thread Claudio Freire
On Thu, Feb 6, 2014 at 3:08 PM, Michael Bayer mike...@zzzcomputing.com wrote: I was imagining/hoping I'd find something like this: # prepare the query: myPreparedQuery = mySession.query(stuff).filter(parameter definitions).prepare() # run the query whenever I need it during my

Re: [sqlalchemy] Automap and naming of relationship attributes

2014-02-06 Thread Adrian Robert
Well, using the mapper event would be nicer, but in any case I was already iterating over Base.classes and adding them to my own module's namespace like so: globals()[cls.__name__] = cls It works for the rest of my application being able to see the classes by importing the module, but

Re: [sqlalchemy] prepared statements

2014-02-06 Thread Jonathan Vanasco
just wondering -- would it be possible to mimic this behavior using a custom view for this select ( in postgresql ) and then querying that ? i think the query planner might only run on the creation. -- You received this message because you are subscribed to the Google Groups sqlalchemy

Re: [sqlalchemy] prepared statements

2014-02-06 Thread Claudio Freire
On Thu, Feb 6, 2014 at 4:00 PM, Jonathan Vanasco jonat...@findmeon.com wrote: just wondering -- would it be possible to mimic this behavior using a custom view for this select ( in postgresql ) and then querying that ? i think the query planner might only run on the creation. I think views

Re: [sqlalchemy] prepared statements

2014-02-06 Thread Michael Bayer
On Feb 6, 2014, at 1:31 PM, Claudio Freire klaussfre...@gmail.com wrote: There are various performance concerns related to SELECT queries and solving them depends much on identifying where a particular performance issue resides. There's overhead on the side of Python/SQLAlchemy

Re: [sqlalchemy] prepared statements

2014-02-06 Thread Claudio Freire
On Thu, Feb 6, 2014 at 4:29 PM, Rick Otten rottenwindf...@gmail.com wrote: Thanks Claudio - I'll mull over the pros and cons of explicitly managing the connections to prepare the statements vs just being patient while the job runs vs gains I might achieve elsewhere. Remember, prepared

Re: [sqlalchemy] prepared statements

2014-02-06 Thread Claudio Freire
On Thu, Feb 6, 2014 at 4:38 PM, Michael Bayer mike...@zzzcomputing.com wrote: On Feb 6, 2014, at 1:31 PM, Claudio Freire klaussfre...@gmail.com wrote: There are various performance concerns related to SELECT queries and solving them depends much on identifying where a particular performance

Re: [sqlalchemy] prepared statements

2014-02-06 Thread Michael Bayer
On Feb 6, 2014, at 2:43 PM, Claudio Freire klaussfre...@gmail.com wrote: On Thu, Feb 6, 2014 at 4:38 PM, Michael Bayer mike...@zzzcomputing.com wrote: On Feb 6, 2014, at 1:31 PM, Claudio Freire klaussfre...@gmail.com wrote: There are various performance concerns related to SELECT

Re: [sqlalchemy] Automap and naming of relationship attributes

2014-02-06 Thread Michael Bayer
On Feb 6, 2014, at 1:56 PM, Adrian Robert adrian.b.rob...@gmail.com wrote: Well, using the mapper event would be nicer, but in any case I was already iterating over Base.classes and adding them to my own module's namespace like so: globals()[cls.__name__] = cls It works for the

Re: [sqlalchemy] prepared statements

2014-02-06 Thread Claudio Freire
On Thu, Feb 6, 2014 at 4:47 PM, Michael Bayer mike...@zzzcomputing.com wrote: On Feb 6, 2014, at 2:43 PM, Claudio Freire klaussfre...@gmail.com wrote: On Thu, Feb 6, 2014 at 4:38 PM, Michael Bayer mike...@zzzcomputing.com wrote: On Feb 6, 2014, at 1:31 PM, Claudio Freire

Re: [sqlalchemy] prepared statements

2014-02-06 Thread Michael Bayer
On Feb 6, 2014, at 2:58 PM, Claudio Freire klaussfre...@gmail.com wrote: On Thu, Feb 6, 2014 at 4:47 PM, Michael Bayer mike...@zzzcomputing.com wrote: On Feb 6, 2014, at 2:43 PM, Claudio Freire klaussfre...@gmail.com wrote: On Thu, Feb 6, 2014 at 4:38 PM, Michael Bayer

Re: [sqlalchemy] SQLite: OperationalError when decoding 0x92 in TEXT column

2014-02-06 Thread Erich Blume
Hmm, this one has me stumped. As best I can tell after poking at it using the column_reflect event, a custom dialect, etc. - the issue here is that in pysqlite.py we (in my Python 3.3 install) are selecting `sqlite3.dbapi2` as the dbapi interface, but we aren't telling sqlite3 anything about

Re: [sqlalchemy] SQLite: OperationalError when decoding 0x92 in TEXT column

2014-02-06 Thread Michael Bayer
On Feb 6, 2014, at 6:59 PM, Erich Blume blume.er...@gmail.com wrote: Hmm, this one has me stumped. As best I can tell after poking at it using the column_reflect event, a custom dialect, etc. - the issue here is that in pysqlite.py we (in my Python 3.3 install) are selecting

Re: [sqlalchemy] prepared statements

2014-02-06 Thread Jonathan Vanasco
On Thursday, February 6, 2014 2:18:51 PM UTC-5, Klauss wrote: I think views don't cache the plan, they're handled as rules. What you'd need is a function (pg's version of stored procedures). I had time to look it up; this generally seems correct. Looking at some explain syntax, it seems