[pgpool-general: 7439] Re: Supported python async drivers

Tatsuo Ishii ishii at sraoss.co.jp
Wed Mar 17 22:20:54 JST 2021


>> Hi,
>> 
>> I am using pgpool2 for failover (and maybe later load balancing, it's a
>> long story...) and am starting to migrate some of my code to use async.
>> Many async projects that support postgres I have seen do so via asyncpg.
>> asyncpg doesn't seem to work at all with pgpool2 (at least with my current
>> pgpool config, which works perfectly synchronously with psycopg2). Basic
>> initial testing suggests aiopg does support pgpool2, at least for what I
>> tested it with. This is probably because it is based on psycopg2-binary.
>> 
>> Unfortunately almost all of the projects I have been looking at using that
>> require async postgres only support asyncpg (Broadcaster, TortoiseORM,...),
>> not aiopg.
>> 
>> Is there an officially supported async driver for python? Is one planned?
> 
> I am not familiar with "async" nor "asyncpg". To understand what they
> are doing, it would be helpful to config Pgpool-II with
> log_client_messages = on and share the pgpool log.

I have tried with asyncpg myself. (see attached python
program. Forgive me if there's something wrong. This is my first
python script:-) With log_client_messages = on, and log_connections =
on it seems Pgpool-II works fine.

2021-03-17 22:15:33: child pid 28311: LOG:  new connection received
2021-03-17 22:15:33: child pid 28311: DETAIL:  connecting host=127.0.0.1 port=33452
2021-03-17 22:15:33: [unknown] pid 28311: LOG:  Parse message from frontend.
2021-03-17 22:15:33: [unknown] pid 28311: DETAIL:  statement: "__asyncpg_stmt_1__", query: "SELECT 1;"
2021-03-17 22:15:33: [unknown] pid 28311: LOG:  DB node id: 0 backend pid: 28670 statement: SELECT version()
2021-03-17 22:15:33: [unknown] pid 28311: LOG:  DB node id: 2 backend pid: 28669 statement: Parse: SELECT 1;
2021-03-17 22:15:33: [unknown] pid 28311: LOG:  Describe message from frontend.
2021-03-17 22:15:33: [unknown] pid 28311: DETAIL:  statement: "__asyncpg_stmt_1__"
2021-03-17 22:15:33: [unknown] pid 28311: LOG:  DB node id: 2 backend pid: 28669 statement: D message
2021-03-17 22:15:33: [unknown] pid 28311: LOG:  Sync message from frontend.
2021-03-17 22:15:33: [unknown] pid 28311: LOG:  Bind message from frontend.
2021-03-17 22:15:33: [unknown] pid 28311: DETAIL:  portal: "", statement: "__asyncpg_stmt_1__"
2021-03-17 22:15:33: [unknown] pid 28311: LOG:  DB node id: 2 backend pid: 28669 statement: Bind: SELECT 1;
2021-03-17 22:15:33: [unknown] pid 28311: LOG:  Execute message from frontend.
2021-03-17 22:15:33: [unknown] pid 28311: DETAIL:  portal: ""
2021-03-17 22:15:33: [unknown] pid 28311: LOG:  DB node id: 2 backend pid: 28669 statement: Execute: SELECT 1;
2021-03-17 22:15:33: [unknown] pid 28311: LOG:  Sync message from frontend.
2021-03-17 22:15:33: [unknown] pid 28311: LOG:  Terminate message from frontend.
2021-03-17 22:15:33: [unknown] pid 28311: LOG:  DB node id: 0 backend pid: 28670 statement:  DISCARD ALL
2021-03-17 22:15:33: [unknown] pid 28311: LOG:  DB node id: 2 backend pid: 28669 statement:  DISCARD ALL

Best regards,
--
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php
Japanese:http://www.sraoss.co.jp


More information about the pgpool-general mailing list