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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With