Psycopg and prepared SQL statements

Поиск
Список
Период
Сортировка
Искать
От
Nicolas Boullis
Тема
Psycopg and prepared SQL statements
Дата
в 12:22:38
Msg-id
20140516122222.GA5010@tryphon.debian.net
Список
Дерево обсуждения
Psycopg and prepared SQL statements Nicolas Boullis <postgresql@ilcode.fr>
Re: Psycopg and prepared SQL statements Christophe Pettus <xof@thebuild.com>
Re: Psycopg and prepared SQL statements Nicolas Boullis <postgresql@ilcode.fr>
Re: Psycopg and prepared SQL statements Daniele Varrazzo <daniele.varrazzo@gmail.com>
Re: Psycopg and prepared SQL statements Nicolas Boullis <postgresql@ilcode.fr>
Hi,

Lately, I’ve been designing and writing a WSGI webapp for which 
performance matters. This webapp queries a PostgreSQL database.

As performance matters, I am using a ThreadedConnectionPool from 
psycopg2.pool, but I also want to have my SQL statements prepared.

I read 
  http://initd.org/psycopg/articles/2012/10/01/prepared-statements-psycopg/
but I could not find a way to mix PreparingCursor with the connection 
pool.
Each statement should definitely be prepared only once for each 
connection, and I could not find a way to attach the prepared cursors to 
the connections in the pool.

So i designed a class that wraps SQL statements, and a class whose 
instances are connection factories that prepare the needed statements.

Here is the result of my work, wit a simple example.

All comments are welcome. I think it woul be nice if psycopg could offer 
a way to use prepared statements.


Cheers,

-- 
Nicolas Boullis
В списке psycopg по дате отправления
От: Daniele Varrazzo
Дата:
Сообщение: Psycopg 2.5.3 released
От: Christophe Pettus
Дата:
FAQ