Reputation: 3118
I want to import specifically the connection
class from psycopg2 because I want to specify that the argument to one of my functions is indeed a valid psycopg2 connection.
But I am having trouble locating exactly where it is stored. The doc page is here but I can't seem to find any reference to where it is defined, and poking around in the source code has left me more confused.
So far I have tried:
from psycopg2 import connection
from psycopg2.extensions import connection
from psycopg2.extras import connection
from psycopg2.sql import connection
But none of them are valid references
Upvotes: 4
Views: 3380
Reputation: 4483
You can find it here:
from psycopg2._psycopg import connection
But this is an internal object, so you shouldn't do that. It is meant that connection objects are created via psycopg2.connect()
factory method.
Upvotes: 5