psycopg
モジュール#
Psycopg implements the Python Database DB API 2.0 specification. As such it also exposes the module-level objects required by the specifications.
- psycopg.connect(conninfo: str = '', *, autocommit: bool = False, prepare_threshold: Optional[int] = 5, row_factory: Optional[RowFactory[Row]] = None, cursor_factory: Optional[Type[Cursor[Row]]] = None, context: Optional[AdaptContext] = None, **kwargs: Any) Connection[Any] #
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.
Exceptions
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
- psycopg.adapters#
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()
. Itstypes
attribute is aTypesRegistry
containing information about every PostgreSQL builtin type, useful for adaptation customisation (see データ適応の設定):>>> psycopg.adapters.types["int4"] <TypeInfo: int4 (oid: 23, array oid: 1007)>
- Type: