Skip to content Skip to sidebar Skip to footer

Psycopg2 - Unkeyed Connection

I'm trying to concurrently insert items into a postgres table via ThreadedConnectionPool, but I keep getting psycopg2.pool.PoolError: trying to put unkeyed connection - not sure wh

Solution 1:

You're seeing this error since you're passing None to the putconn() function. Source can be seen at: https://github.com/psycopg/psycopg2/blob/master/lib/pool.py

You should adjust your finally block to be:

    finally:
        cursor.close()
        self.conn.putconn(conn)

I'v encountered the error after forcing a Connection Pool refresh, and had a line that attempted to call putconn(conn) on a connection from the old pool.

Post a Comment for "Psycopg2 - Unkeyed Connection"