librelist archives

« back to archive

psycopg2 connection pool pattern

psycopg2 connection pool pattern

From:
Christian Jauvin
Date:
2012-11-03 @ 16:08
Hi,

I'm interested in using a psycopg2 connection pool with Flask.
However, as I guess that the correct way to do it is related to some
infrastructure details (use of mod_wsgi, threaded or not, etc), I'd
like to have an example pattern (which I can't seem to find) to begin
with. In particular, I'd like to know which type of pool would fit
what environment, and how it can be used in conjunction with the
@app.after_request mechanism.

Thanks,

Christian

Re: [flask] psycopg2 connection pool pattern

From:
Owein Reese
Date:
2012-11-03 @ 16:16
Take a look at Flask-Sqlalchemy. It's a great abstraction layer for sql and
it comes with some nice prebuilt plumbing.
On Nov 3, 2012 12:14 PM, "Christian Jauvin" <cjauvin@gmail.com> wrote:

> Hi,
>
> I'm interested in using a psycopg2 connection pool with Flask.
> However, as I guess that the correct way to do it is related to some
> infrastructure details (use of mod_wsgi, threaded or not, etc), I'd
> like to have an example pattern (which I can't seem to find) to begin
> with. In particular, I'd like to know which type of pool would fit
> what environment, and how it can be used in conjunction with the
> @app.after_request mechanism.
>
> Thanks,
>
> Christian
>

Re: [flask] psycopg2 connection pool pattern

From:
Christian Jauvin
Date:
2012-11-03 @ 16:37
> Take a look at Flask-Sqlalchemy. It's a great abstraction layer for sql and
> it comes with some nice prebuilt plumbing.

Thanks Owein. I forgot to say that I'd actually prefer a non-plugin
solution/pattern, as I'm already using a small module I wrote as a
very thin layer above psycopg2, and which I use as a replacement for a
full-blown ORM.