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
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.