The psycopg module
psycopg.connect(conninfo='', *, autocommit=False, prepare_threshold=5, row_factory=None, cursor_factory=None, context=None, **kwargs)
Connect to a database server and return a new Connection instance.
This is an alias of the class method Connection.connect: see its documentation for details.
If you need an asynchronous connection use AsyncConnection.connect instead.
The standard DBAPI exceptions are exposed both by the !psycopg module and by the psycopg.errors module. The latter also exposes more specific exceptions, mapping to the database error states (see SQLSTATE exceptions).
!Exception |__ Warning |__ Error |__ InterfaceError |__ DatabaseError |__ DataError |__ OperationalError |__ IntegrityError |__ InternalError |__ ProgrammingError |__ NotSupportedError
The default adapters map establishing how Python and PostgreSQL types are converted into each other.
This map is used as a template when new connections are created, using psycopg.connect(). Its ~psycopg.adapt.AdaptersMap.types attribute is a ~psycopg.types.TypesRegistry containing information about every PostgreSQL builtin type, useful for adaptation customisation (see Data adaptation configuration):
>>> psycopg.adapters.types["int4"] <TypeInfo: int4 (oid: 23, array oid: 1007)>