psycopg API reference
278 public APIs from psycopg (psycopg/psycopg) — 92 classes, 48 functions, 138 methods. Signatures extracted by static analysis of the actual source.
Repository: psycopg/psycopg
| Kind | Count |
|---|---|
| Classes | 92 |
| Functions | 48 |
| Methods | 138 |
API list
class
psycopg.psycopg._acompat.QueueA Queue subclass with an interruptible get() method.
func
psycopg.psycopg._acompat.agather(*timeout:float | None=None, *tasks:asyncio.Task[Any]) -> NoneEquivalent to asyncio.gather or Thread.join()
func
psycopg.psycopg._acompat.aspawn(f:Callable[..., Coroutine[Any, Any, None]], args:tuple[Any, ...]=(), name:str | None=None) -> asyncio.Task[None]Equivalent to asyncio.create_task.
func
psycopg.psycopg._acompat.gather(*timeout:float | None=None, *tasks:threading.Thread) -> NoneEquivalent to asyncio.gather or Thread.join()
func
psycopg.psycopg._acompat.spawn(f:Callable[..., Any], args:tuple[Any, ...]=(), name:str | None=None) -> threading.ThreadEquivalent to creating and running a daemon thread.
method
psycopg.psycopg._capabilities.Capabilities.has_cancel_safe(check:bool=False) -> boolCheck if the `Connection.cancel_safe()` method is implemented.
method
psycopg.psycopg._column.Column.name() -> strThe name of the column.
method
psycopg.psycopg._column.Column.null_ok() -> bool | NoneAlways `!None`
method
psycopg.psycopg._column.Column.precision() -> int | NoneThe number of digits for fixed precision types.
method
psycopg.psycopg._column.Column.type_code() -> intThe numeric OID of the column.
method
psycopg.psycopg._column.Column.type_display() -> strA pretty representation of the column type.
class
psycopg.psycopg._connection_base.BaseConnectionBase class for different types of connections.
method
psycopg.psycopg._connection_base.BaseConnection.autocommit() -> boolThe autocommit state of the connection.
method
psycopg.psycopg._connection_base.BaseConnection.broken() -> bool`!True` if the connection was interrupted.
method
psycopg.psycopg._connection_base.BaseConnection.cancel() -> NoneCancel the current operation on the connection.
method
psycopg.psycopg._connection_base.BaseConnection.closed() -> bool`!True` if the connection is closed.
method
psycopg.psycopg._connection_base.BaseConnection.fileno() -> intReturn the file descriptor of the connection.
class
psycopg.psycopg._connection_base.NotifyAn asynchronous notification received from the database.
class
psycopg.psycopg._connection_info.ConnectionInfoAllow access to information about the connection.
method
psycopg.psycopg._connection_info.ConnectionInfo.dbname() -> strThe database name of the connection.
method
psycopg.psycopg._connection_info.ConnectionInfo.get_parameters() -> dict[str, str]Return the connection parameters values.
method
psycopg.psycopg._connection_info.ConnectionInfo.host() -> strThe server host name of the active connection.
method
psycopg.psycopg._connection_info.ConnectionInfo.hostaddr() -> strThe server IP address of the connection.
method
psycopg.psycopg._connection_info.ConnectionInfo.parameter_status(param_name:str) -> str | NoneReturn a parameter setting of the connection.
method
psycopg.psycopg._connection_info.ConnectionInfo.password() -> strThe password of the connection.
method
psycopg.psycopg._connection_info.ConnectionInfo.pipeline_status() -> pq.PipelineStatusThe current pipeline status of the client.
method
psycopg.psycopg._connection_info.ConnectionInfo.port() -> intThe port of the active connection.
method
psycopg.psycopg._connection_info.ConnectionInfo.server_version() -> intAn integer representing the server version.
method
psycopg.psycopg._connection_info.ConnectionInfo.status() -> pq.ConnStatusThe status of the connection.
method
psycopg.psycopg._connection_info.ConnectionInfo.user() -> strThe user name of the connection.
class
psycopg.psycopg._conninfo_utils.ParamDefInformation about defaults and env vars for connection params
func
psycopg.psycopg._conninfo_utils.get_param(params:ConnMapping, name:str) -> str | NoneReturn a value from a connection string.
func
psycopg.psycopg._conninfo_utils.get_param_def(keyword:str, _cache:dict[str, ParamDef]={}) -> ParamDef | NoneReturn the ParamDef of a connection string parameter.
func
psycopg.psycopg._conninfo_utils.gssapi_requested(params:ConnDict) -> boolReturn `true` if `gssencmode` was specified explicitly.
func
psycopg.psycopg._conninfo_utils.is_ip_address(s:str) -> boolReturn True if the string represent a valid ip address.
class
psycopg.psycopg._copy.CopyManage an asynchronous :sql:`COPY` operation.
method
psycopg.psycopg._copy.Copy.finish(exc:BaseException | None) -> NoneTerminate the copy operation and free the resources allocated.
method
psycopg.psycopg._copy.Copy.read() -> BufferRead an unparsed row after a :sql:`COPY TO` operation.
method
psycopg.psycopg._copy.Copy.write(buffer:Buffer | str) -> NoneWrite a block of data to a table after a :sql:`COPY FROM` operation.
method
psycopg.psycopg._copy.Copy.write_row(row:Sequence[Any]) -> NoneWrite a record to a table after a :sql:`COPY FROM` operation.
class
psycopg.psycopg._copy.LibpqWriterAn `Writer` to write copy data to a Postgres database.
class
psycopg.psycopg._copy.QueuedLibpqWriter`Writer` using a buffer to queue data to write.
class
psycopg.psycopg._copy.WriterA class to write copy data somewhere (for async connections).
method
psycopg.psycopg._copy.Writer.finish(exc:BaseException | None=None) -> NoneCalled when write operations are finished.
method
psycopg.psycopg._copy.Writer.write(data:Buffer) -> NoneWrite some data to destination.
class
psycopg.psycopg._copy_async.AsyncCopyManage an asynchronous :sql:`COPY` operation.
method
psycopg.psycopg._copy_async.AsyncCopy.finish(exc:BaseException | None) -> NoneTerminate the copy operation and free the resources allocated.
method
psycopg.psycopg._copy_async.AsyncCopy.read() -> BufferRead an unparsed row after a :sql:`COPY TO` operation.
method
psycopg.psycopg._copy_async.AsyncCopy.write_row(row:Sequence[Any]) -> NoneWrite a record to a table after a :sql:`COPY FROM` operation.
class
psycopg.psycopg._copy_async.AsyncQueuedLibpqWriter`AsyncWriter` using a buffer to queue data to write.
class
psycopg.psycopg._copy_async.AsyncWriterA class to write copy data somewhere (for async connections).
method
psycopg.psycopg._copy_async.AsyncWriter.finish(exc:BaseException | None=None) -> NoneCalled when write operations are finished.
method
psycopg.psycopg._copy_async.AsyncWriter.write(data:Buffer) -> NoneWrite some data to destination.
class
psycopg.psycopg._copy_base.BaseCopyBase implementation for the copy user interface.
method
psycopg.psycopg._copy_base.BaseCopy.set_types(types:Sequence[int | str]) -> NoneSet the types expected in a COPY operation.
class
psycopg.psycopg._copy_base.FormatterA class which understand a copy format (text, binary).
method
psycopg.psycopg._cursor_base.BaseCursor.closed() -> bool`True` if the cursor is closed.
method
psycopg.psycopg._cursor_base.BaseCursor.connection() -> ConnectionTypeThe connection this cursor is using.
method
psycopg.psycopg._cursor_base.BaseCursor.statusmessage() -> str | NoneThe status tag of the current result set.
func
psycopg.psycopg._dns.resolve_srv(params:dict[str, Any]) -> dict[str, Any]Apply SRV DNS lookup as defined in :RFC:`2782`.
func
psycopg.psycopg._dns.resolve_srv_async(params:dict[str, Any]) -> dict[str, Any]Async equivalent of `resolve_srv()`.
func
psycopg.psycopg._encodings.conn_encoding(conn:BaseConnection[Any] | None) -> strReturn the Python encoding name of a psycopg connection.
func
psycopg.psycopg._encodings.conninfo_encoding(conninfo:str) -> strReturn the Python encoding name passed in a conninfo string.
func
psycopg.psycopg._encodings.pg2pyenc(name:bytes) -> strConvert a PostgreSQL encoding name to Python encoding name.
func
psycopg.psycopg._encodings.py2pgenc(name:str) -> bytesConvert a Python encoding name to PostgreSQL encoding name.
class
psycopg.psycopg._enums.IsolationLevelEnum representing the isolation level for a transaction.
class
psycopg.psycopg._enums.PyFormatEnum representing the format wanted for a query argument.
class
psycopg.psycopg._pipeline.PipelineHandler for (sync) connection in pipeline mode.
class
psycopg.psycopg._pipeline_async.AsyncPipelineHandler for (async) connection in pipeline mode.
class
psycopg.psycopg._py_transformer.TransformerAn object that can adapt efficiently between Python and PostgreSQL.
method
psycopg.psycopg._py_transformer.Transformer.from_context(context:AdaptContext | None) -> TransformerReturn a Transformer from an AdaptContext.
method
psycopg.psycopg._py_transformer.Transformer.get_dumper(obj:Any, format:PyFormat) -> abc.DumperReturn a Dumper instance to dump `!obj`.
class
psycopg.psycopg._tpc.XidA two-phase commit transaction identifier.
method
psycopg.psycopg._tpc.Xid.from_string(s:str) -> XidTry to parse an XA triple from the string.
func
psycopg.psycopg._tstrings.as_bytes(t:Template, context:abc.AdaptContext | None=None) -> bytesConvert a template string to a bytes string.
func
psycopg.psycopg._tstrings.as_string(t:Template, context:abc.AdaptContext | None=None) -> strConvert a template string to a string.
class
psycopg.psycopg._typeinfo.TypeInfoHold information about a PostgreSQL base type.
method
psycopg.psycopg._typeinfo.TypeInfo.register(context:AdaptContext | None=None) -> NoneRegister the type information, globally or in the specified `!context`.
class
psycopg.psycopg._typeinfo.TypesRegistryContainer for the information about types in a database.
method
psycopg.psycopg._typeinfo.TypesRegistry.get_oid(name:str) -> intReturn the oid of a PostgreSQL type by name.
class
psycopg.psycopg._typemod.BitTypeModifierHandle bit/varbit type modifier.
class
psycopg.psycopg._typemod.CharTypeModifierHandle char/varchar type modifier.
class
psycopg.psycopg._typemod.NumericTypeModifierHandle numeric type modifier.
class
psycopg.psycopg._typemod.TimeTypeModifierHandle time-related types modifier.
class
psycopg.psycopg._typemod.TypeModifierType modifier that doesn't know any modifier.
func
psycopg.psycopg._tz.get_tzinfo(pgconn:PGconn | None) -> tzinfoReturn the Python timezone info of the connection's timezone.
class
psycopg.psycopg._wrappers.OidForce dumping a Python `!int` as a PostgreSQL :sql:`oid`.
class
psycopg.psycopg.abc.AdaptContextA context describing how types are adapted.
method
psycopg.psycopg.abc.AdaptContext.adapters() -> AdaptersMapThe adapters configuration that this object uses.
method
psycopg.psycopg.abc.AdaptContext.connection() -> BaseConnection[Any] | NoneThe connection used by this object, if available.
method
psycopg.psycopg.abc.Dumper.dump(obj:Any) -> Buffer | NoneConvert the object `!obj` to PostgreSQL representation.
method
psycopg.psycopg.abc.Dumper.get_key(obj:Any, format:PyFormat) -> DumperKeyReturn an alternative key to upgrade the dumper to represent `!obj`.
method
psycopg.psycopg.abc.Dumper.quote(obj:Any) -> BufferConvert the object `!obj` to escaped representation.
method
psycopg.psycopg.abc.Dumper.upgrade(obj:Any, format:PyFormat) -> DumperReturn a new dumper to manage `!obj`.
class
psycopg.psycopg.abc.LoaderConvert PostgreSQL values with type OID `!oid` to Python objects.
method
psycopg.psycopg.abc.Loader.load(data:Buffer) -> AnyConvert the data returned by the database into a Python object.
method
psycopg.psycopg.adapt.Loader.load(data:Buffer) -> AnyConvert a PostgreSQL value to a Python object.
class
psycopg.psycopg.adapt.RecursiveDumperDumper with a transformer to help dumping recursive types.
class
psycopg.psycopg.adapt.RecursiveLoaderLoader with a transformer to help loading recursive types.
class
psycopg.psycopg.connection.ConnectionWrapper for a connection to the database.
method
psycopg.psycopg.connection.Connection.cancel_safe(*timeout:float=30.0) -> NoneCancel the current operation on the connection.
method
psycopg.psycopg.connection.Connection.close() -> NoneClose the database connection.
method
psycopg.psycopg.connection.Connection.commit() -> NoneCommit any pending transaction to the database.
method
psycopg.psycopg.connection.Connection.rollback() -> NoneRoll back to the start of any pending transaction.
method
psycopg.psycopg.connection.Connection.set_autocommit(value:bool) -> NoneMethod version of the `~Connection.autocommit` setter.
method
psycopg.psycopg.connection.Connection.set_deferrable(value:bool | None) -> NoneMethod version of the `~Connection.deferrable` setter.
method
psycopg.psycopg.connection.Connection.set_isolation_level(value:IsolationLevel | None) -> NoneMethod version of the `~Connection.isolation_level` setter.
method
psycopg.psycopg.connection.Connection.set_read_only(value:bool | None) -> NoneMethod version of the `~Connection.read_only` setter.
method
psycopg.psycopg.connection.Connection.tpc_begin(xid:Xid | str) -> NoneBegin a TPC transaction with the given transaction ID `!xid`.
method
psycopg.psycopg.connection.Connection.tpc_commit(xid:Xid | str | None=None) -> NoneCommit a prepared two-phase transaction.
method
psycopg.psycopg.connection.Connection.tpc_rollback(xid:Xid | str | None=None) -> NoneRoll back a prepared two-phase transaction.
method
psycopg.psycopg.connection.Connection.wait(gen:PQGen[RV], interval:float=_WAIT_INTERVAL) -> RVConsume a generator operating on the connection.
class
psycopg.psycopg.connection_async.AsyncConnectionWrapper for a connection to the database.
method
psycopg.psycopg.connection_async.AsyncConnection.cancel_safe(*timeout:float=30.0) -> NoneCancel the current operation on the connection.
method
psycopg.psycopg.connection_async.AsyncConnection.close() -> NoneClose the database connection.
method
psycopg.psycopg.connection_async.AsyncConnection.commit() -> NoneCommit any pending transaction to the database.
method
psycopg.psycopg.connection_async.AsyncConnection.rollback() -> NoneRoll back to the start of any pending transaction.
method
psycopg.psycopg.connection_async.AsyncConnection.set_autocommit(value:bool) -> NoneMethod version of the `~Connection.autocommit` setter.
method
psycopg.psycopg.connection_async.AsyncConnection.set_deferrable(value:bool | None) -> NoneMethod version of the `~Connection.deferrable` setter.
method
psycopg.psycopg.connection_async.AsyncConnection.set_read_only(value:bool | None) -> NoneMethod version of the `~Connection.read_only` setter.
method
psycopg.psycopg.connection_async.AsyncConnection.tpc_begin(xid:Xid | str) -> NoneBegin a TPC transaction with the given transaction ID `!xid`.
method
psycopg.psycopg.connection_async.AsyncConnection.tpc_commit(xid:Xid | str | None=None) -> NoneCommit a prepared two-phase transaction.
method
psycopg.psycopg.connection_async.AsyncConnection.tpc_rollback(xid:Xid | str | None=None) -> NoneRoll back a prepared two-phase transaction.
method
psycopg.psycopg.connection_async.AsyncConnection.wait(gen:PQGen[RV], interval:float=_WAIT_INTERVAL) -> RVConsume a generator operating on the connection.
func
psycopg.psycopg.conninfo.conninfo_to_dict(conninfo:str='', **kwargs:ConnParam) -> ConnDictConvert the `!conninfo` string into a dictionary of parameters.
func
psycopg.psycopg.conninfo.make_conninfo(conninfo:str='', **kwargs:ConnParam) -> strMerge a string and keyword params into a single conninfo string.
func
psycopg.psycopg.conninfo.timeout_from_conninfo(params:ConnDict) -> intReturn the timeout in seconds from the connection parameters.
class
psycopg.psycopg.copy.FileWriterA `Writer` to write copy data to a file-like object.
class
psycopg.psycopg.crdb.connection.CrdbConnectionWrapper for a connection to a CockroachDB database.
method
psycopg.psycopg.cursor.Cursor.close() -> NoneClose the current cursor and free associated resources.
method
psycopg.psycopg.cursor.Cursor.executemany(query:Query, params_seq:Iterable[Params], *returning:bool=False) -> NoneExecute the same command with a sequence of input data.
method
psycopg.psycopg.cursor.Cursor.fetchmany(size:int=0) -> list[Row]Return the next `!size` records from the current result set.
method
psycopg.psycopg.cursor.Cursor.fetchone() -> Row | NoneReturn the next record from the current result set.
method
psycopg.psycopg.cursor.Cursor.set_result(index:int) -> SelfMove to a specific result set.
method
psycopg.psycopg.cursor.Cursor.stream(query:Query, params:Params | None=None, *binary:bool | None=None, *size:int=1) -> Iterator[Row]Iterate row-by-row on a result from the database.
method
psycopg.psycopg.cursor_async.AsyncCursor.close() -> NoneClose the current cursor and free associated resources.
method
psycopg.psycopg.cursor_async.AsyncCursor.fetchmany(size:int=0) -> list[Row]Return the next `!size` records from the current result set.
method
psycopg.psycopg.cursor_async.AsyncCursor.fetchone() -> Row | NoneReturn the next record from the current result set.
method
psycopg.psycopg.cursor_async.AsyncCursor.set_result(index:int) -> SelfMove to a specific result set.
class
psycopg.psycopg.errors.DataErrorAn error caused by problems with the processed data.
class
psycopg.psycopg.errors.DatabaseErrorException raised for errors that are related to the database.
class
psycopg.psycopg.errors.DiagnosticDetails from a database error report.
class
psycopg.psycopg.errors.ErrorBase exception for all the errors psycopg will raise.
class
psycopg.psycopg.errors.FinishedPGconnFinished libpq connection.
class
psycopg.psycopg.errors.OperationalErrorAn error related to the database's operation.
class
psycopg.psycopg.errors.WarningException raised for important warnings.
func
psycopg.psycopg.errors.lookup(sqlstate:str) -> type[Error]Lookup an error code or `constant name`__ and return its exception class.
class
psycopg.psycopg.pq._debug.PGconnDebugWrapper for a PQconn logging all its access.
func
psycopg.psycopg.pq._debug.debugging(f:Func) -> FuncWrap a function in order to log its arguments and return value on call.
class
psycopg.psycopg.pq._enums.ConnStatusCurrent status of the connection.
class
psycopg.psycopg.pq._enums.DiagnosticFieldFields in an error report.
class
psycopg.psycopg.pq._enums.ExecStatusThe status of a command.
class
psycopg.psycopg.pq._enums.PingResponse from a ping attempt.
class
psycopg.psycopg.pq._enums.PipelineStatusPipeline mode status of the libpq connection.
class
psycopg.psycopg.pq._enums.PollingStatusThe status of the socket during a connection.
class
psycopg.psycopg.pq._enums.TraceEnum to control tracing of the client/server communication.
class
psycopg.psycopg.pq._enums.TransactionStatusThe transaction status of a connection.
func
psycopg.psycopg.pq.misc.connection_summary(pgconn:abc.PGconn) -> strReturn summary information on a connection.
func
psycopg.psycopg.pq.misc.get_compiled_port() -> strReturn the default port compiled with the libpq.
func
psycopg.psycopg.pq.misc.strip_severity(msg:str) -> strStrip severity and whitespaces from error message.
class
psycopg.psycopg.pq.pq_ctypes.ConninfoUtility object to manipulate connection strings.
class
psycopg.psycopg.pq.pq_ctypes.EscapingUtility object to escape strings for SQL interpolation.
class
psycopg.psycopg.pq.pq_ctypes.PGcancelToken to cancel the current operation on a connection.
method
psycopg.psycopg.pq.pq_ctypes.PGcancel.free(__PQfreeCancel:Any=impl.PQfreeCancel) -> NoneFree the data structure created by :pq:`PQgetCancel()`.
class
psycopg.psycopg.pq.pq_ctypes.PGcancelConnToken to handle non-blocking cancellation requests.
method
psycopg.psycopg.pq.pq_ctypes.PGcancelConn.finish(__PQcancelFinish:Any=impl.PQcancelFinish) -> NoneFree the data structure created by `PQcancelCreate()`.
class
psycopg.psycopg.pq.pq_ctypes.PGconnPython representation of a libpq connection.
method
psycopg.psycopg.pq.pq_ctypes.PGconn.change_password(user:bytes, passwd:bytes) -> NoneChange a PostgreSQL password.
method
psycopg.psycopg.pq.pq_ctypes.PGconn.encrypt_password(passwd:bytes, user:bytes, algorithm:bytes | None=None) -> bytesReturn the encrypted form of a PostgreSQL password.
method
psycopg.psycopg.pq.pq_ctypes.PGconn.enter_pipeline_mode() -> NoneEnter pipeline mode.
method
psycopg.psycopg.pq.pq_ctypes.PGconn.exit_pipeline_mode() -> NoneExit pipeline mode.
method
psycopg.psycopg.pq.pq_ctypes.PGconn.pipeline_sync() -> NoneMark a synchronization point in a pipeline.
method
psycopg.psycopg.pq.pq_ctypes.PGconn.set_trace_flags(flags:Trace) -> NoneConfigure tracing behavior of client/server communication.
method
psycopg.psycopg.pq.pq_ctypes.PGconn.trace(fileno:int) -> NoneEnable tracing of the client/server communication to a file stream.
method
psycopg.psycopg.pq.pq_ctypes.PGconn.untrace() -> NoneDisable tracing, previously enabled through `trace()`.
class
psycopg.psycopg.pq.pq_ctypes.PGresultPython representation of a libpq result.
func
psycopg.psycopg.pq.pq_ctypes.version() -> intReturn the version number of the libpq currently loaded.
class
psycopg.psycopg.rows.AsyncRowFactoryLike `RowFactory`, taking an async cursor as argument.
class
psycopg.psycopg.rows.BaseRowFactoryLike `RowFactory`, taking either type of cursor as argument.
func
psycopg.psycopg.rows.dict_row(cursor:BaseCursor[Any, Any]) -> RowMaker[DictRow]Row factory to represent rows as dictionaries.
func
psycopg.psycopg.rows.namedtuple_row(cursor:BaseCursor[Any, Any]) -> RowMaker[NamedTuple]Row factory to represent rows as `~collections.namedtuple`.
func
psycopg.psycopg.rows.no_result(values:Sequence[Any]) -> NoReturnA `RowMaker` that always fail.
func
psycopg.psycopg.rows.tuple_row(cursor:BaseCursor[Any, Any]) -> RowMaker[TupleRow]Row factory to represent rows as simple tuples.
class
psycopg.psycopg.sql.ComposableAbstract base class for objects that can be used to compose an SQL string.
method
psycopg.psycopg.sql.Composable.as_bytes(context:AdaptContext | None=None) -> bytesReturn the value of the object as bytes.
method
psycopg.psycopg.sql.Composable.as_string(context:AdaptContext | None=None) -> strReturn the value of the object as string.
class
psycopg.psycopg.sql.ComposedA `Composable` object made of a sequence of `!Composable`.
method
psycopg.psycopg.sql.Composed.join(joiner:SQL | LiteralString) -> ComposedReturn a new `!Composed` interposing the `!joiner` with the `!Composed` items.
class
psycopg.psycopg.sql.LiteralA `Composable` representing an SQL value to include in a query.
class
psycopg.psycopg.sql.SQLA `Composable` representing a snippet of SQL statement.
method
psycopg.psycopg.sql.SQL.format(*args:Any, **kwargs:Any) -> ComposedMerge `Composable` objects into a template.
func
psycopg.psycopg.sql.as_bytes(obj:Any, context:AdaptContext | None=None) -> bytesConvert an object to a bytes string according to SQL rules.
func
psycopg.psycopg.sql.as_string(obj:Any, context:AdaptContext | None=None) -> strConvert an object to a string according to SQL rules.
func
psycopg.psycopg.sql.quote(obj:Any, context:AdaptContext | None=None) -> strAdapt a Python object to a quoted SQL string.
method
psycopg.psycopg.transaction.AsyncTransaction.connection() -> AsyncConnection[Any]The connection the object is managing.
class
psycopg.psycopg.transaction.BaseTransaction.StatusThe current status of a transaction.
class
psycopg.psycopg.transaction.OutOfOrderTransactionNestingOut-of-order transaction nesting detected
method
psycopg.psycopg.transaction.Transaction.connection() -> Connection[Any]The connection the object is managing.
func
psycopg.psycopg.types.array.register_all_arrays(context:AdaptContext) -> NoneAssociate the array oid of all the types in Loader.globals.
class
psycopg.psycopg.types.composite.CompositeInfoManage information about a composite type.
class
psycopg.psycopg.types.composite.RecordBinaryLoaderLoad a `record` field from PostgreSQL.
class
psycopg.psycopg.types.composite.RecordLoaderLoad a `record` field from PostgreSQL.
class
psycopg.psycopg.types.enum.EnumDumperDumper for a generic Enum class
class
psycopg.psycopg.types.enum.EnumInfoManage information about an enum type.
func
psycopg.psycopg.types.hstore.register_hstore(info:TypeInfo, context:AdaptContext | None=None) -> NoneRegister the adapters to load and dump hstore.
class
psycopg.psycopg.types.multirange.MultirangePython representation for a PostgreSQL multirange type.
class
psycopg.psycopg.types.multirange.MultirangeDumperDumper for multirange types.
class
psycopg.psycopg.types.multirange.MultirangeInfoManage information about a multirange type.
class
psycopg.psycopg.types.range.BaseRangeLoaderGeneric loader for a range.
class
psycopg.psycopg.types.range.RangePython representation for a PostgreSQL range type.
method
psycopg.psycopg.types.range.Range.isempty() -> bool`!True` if the range is empty.
method
psycopg.psycopg.types.range.Range.lower() -> T | NoneThe lower bound of the range.
method
psycopg.psycopg.types.range.Range.lower_inc() -> bool`!True` if the lower bound is included in the range.
method
psycopg.psycopg.types.range.Range.lower_inf() -> bool`!True` if the range doesn't have a lower bound.
method
psycopg.psycopg.types.range.Range.upper() -> T | NoneThe upper bound of the range.
method
psycopg.psycopg.types.range.Range.upper_inc() -> bool`!True` if the upper bound is included in the range.
method
psycopg.psycopg.types.range.Range.upper_inf() -> bool`!True` if the range doesn't have an upper bound.
class
psycopg.psycopg.types.range.RangeDumperDumper for range types.
class
psycopg.psycopg.types.range.RangeInfoManage information about a range type.
func
psycopg.psycopg.types.range.register_range(info:RangeInfo, context:AdaptContext | None=None) -> NoneRegister the adapters to load and dump a range type.
func
psycopg.psycopg.types.shapely.register_shapely(info:TypeInfo, context:AdaptContext | None=None) -> NoneRegister Shapely dumper and loaders.
class
psycopg.psycopg.types.string.StrDumperDumper for strings in text format to the text oid.
class
psycopg.psycopg.types.string.StrDumperUnknownDumper for strings in text format to the unknown oid.
func
psycopg.psycopg.waiting.wait_async(gen:PQGen[RV], fileno:int, interval:float=0.0) -> RVCoroutine waiting for a generator to complete.
func
psycopg.psycopg.waiting.wait_conn(gen:PQGenConn[RV], interval:float=0.0) -> RVWait for a connection generator using the best strategy available.
func
psycopg.psycopg.waiting.wait_conn_async(gen:PQGenConn[RV], interval:float=0.0) -> RVCoroutine waiting for a connection generator to complete.
func
psycopg.psycopg.waiting.wait_epoll(gen:PQGen[RV], fileno:int, interval:float=0.0) -> RVWait for a generator using epoll where supported.
func
psycopg.psycopg.waiting.wait_poll(gen:PQGen[RV], fileno:int, interval:float=0.0) -> RVWait for a generator using poll where supported.
func
psycopg.psycopg.waiting.wait_select(gen:PQGen[RV], fileno:int, interval:float=0.0) -> RVWait for a generator using select where supported.
func
psycopg.psycopg.waiting.wait_selector(gen:PQGen[RV], fileno:int, interval:float=0.0) -> RVWait for a generator using the best strategy available.
class
psycopg_pool.psycopg_pool._acompat.QueueA Queue subclass with an interruptible get() method.
func
psycopg_pool.psycopg_pool._acompat.agather(*timeout:float | None=None, *timeout_hint:str='', *tasks:asyncio.Task[Any]) -> NoneEquivalent to asyncio.gather or Thread.join()
func
psycopg_pool.psycopg_pool._acompat.aspawn(f:Callable[..., Coroutine[Any, Any, None]], args:tuple[Any, ...]=(), name:str | None=None) -> asyncio.Task[None]Equivalent to asyncio.create_task.
func
psycopg_pool.psycopg_pool._acompat.gather(*timeout:float | None=None, *timeout_hint:str='', *tasks:threading.Thread) -> NoneEquivalent to asyncio.gather or Thread.join()
func
psycopg_pool.psycopg_pool._acompat.spawn(f:Callable[..., Any], args:tuple[Any, ...]=(), name:str | None=None) -> threading.ThreadEquivalent to creating and running a daemon thread.
method
psycopg_pool.psycopg_pool.base.BasePool.closed() -> bool`!True` if the pool is closed.
method
psycopg_pool.psycopg_pool.base.BasePool.get_stats() -> dict[str, int]Return current stats about the pool usage.
method
psycopg_pool.psycopg_pool.base.BasePool.pop_stats() -> dict[str, int]Return current stats about the pool usage.
class
psycopg_pool.psycopg_pool.errors.PoolClosedAttempt to get a connection from a closed pool.
class
psycopg_pool.psycopg_pool.errors.PoolTimeoutThe pool couldn't provide a connection in acceptable time.
method
psycopg_pool.psycopg_pool.pool.ConnectionPool.check_connection(conn:CT) -> NoneA simple check to verify that a connection is still working.
method
psycopg_pool.psycopg_pool.pool.ConnectionPool.close(timeout:float=5.0) -> NoneClose the pool and make it unavailable to new clients.
method
psycopg_pool.psycopg_pool.pool.ConnectionPool.connection(timeout:float | None=None) -> Iterator[CT]Context manager to obtain a connection from the pool.
method
psycopg_pool.psycopg_pool.pool.ConnectionPool.getconn(timeout:float | None=None) -> CTObtain a connection from the pool.
method
psycopg_pool.psycopg_pool.pool.ConnectionPool.putconn(conn:CT) -> NoneReturn a connection to the loving hands of its pool.
method
psycopg_pool.psycopg_pool.pool.ConnectionPool.resize(min_size:int, max_size:int | None=None) -> NoneChange the size of the pool during runtime.
method
psycopg_pool.psycopg_pool.pool.ConnectionPool.run_task(task:MaintenanceTask) -> NoneRun a maintenance task in a worker.
method
psycopg_pool.psycopg_pool.pool.ConnectionPool.schedule_task(task:MaintenanceTask, delay:float) -> NoneRun a maintenance task in a worker in the future.
method
psycopg_pool.psycopg_pool.pool.ConnectionPool.worker(q:Queue[MaintenanceTask]) -> NoneRunner to execute pending maintenance task.
class
psycopg_pool.psycopg_pool.pool.MaintenanceTaskA task to run asynchronously to maintain the pool state.
method
psycopg_pool.psycopg_pool.pool.MaintenanceTask.run() -> NoneRun the task.
class
psycopg_pool.psycopg_pool.pool.ReturnConnectionClean up and return a connection to the pool.
class
psycopg_pool.psycopg_pool.pool.ScheduleSchedule a task in the pool scheduler.
class
psycopg_pool.psycopg_pool.pool.ShrinkPoolIf the pool can shrink, remove one connection.
class
psycopg_pool.psycopg_pool.pool.StopWorkerSignal the maintenance worker to terminate.
method
psycopg_pool.psycopg_pool.pool.WaitingClient.fail(error:Exception) -> boolSignal the client that, alas, they won't have a connection today.
method
psycopg_pool.psycopg_pool.pool.WaitingClient.set(conn:CT) -> boolSignal the client waiting that a connection is ready.
method
psycopg_pool.psycopg_pool.pool.WaitingClient.wait(timeout:float) -> CTWait for a connection to be set and return it.
method
psycopg_pool.psycopg_pool.pool_async.AsyncConnectionPool.close(timeout:float=5.0) -> NoneClose the pool and make it unavailable to new clients.
method
psycopg_pool.psycopg_pool.pool_async.AsyncConnectionPool.getconn(timeout:float | None=None) -> ACTObtain a connection from the pool.
method
psycopg_pool.psycopg_pool.pool_async.AsyncConnectionPool.putconn(conn:ACT) -> NoneReturn a connection to the loving hands of its pool.
method
psycopg_pool.psycopg_pool.pool_async.AsyncConnectionPool.resize(min_size:int, max_size:int | None=None) -> NoneChange the size of the pool during runtime.
method
psycopg_pool.psycopg_pool.pool_async.AsyncConnectionPool.run_task(task:MaintenanceTask) -> NoneRun a maintenance task in a worker.
method
psycopg_pool.psycopg_pool.pool_async.AsyncConnectionPool.schedule_task(task:MaintenanceTask, delay:float) -> NoneRun a maintenance task in a worker in the future.
method
psycopg_pool.psycopg_pool.pool_async.AsyncConnectionPool.worker(q:AQueue[MaintenanceTask]) -> NoneRunner to execute pending maintenance task.
method
psycopg_pool.psycopg_pool.pool_async.MaintenanceTask.run() -> NoneRun the task.
class
psycopg_pool.psycopg_pool.pool_async.ReturnConnectionClean up and return a connection to the pool.
class
psycopg_pool.psycopg_pool.pool_async.ScheduleSchedule a task in the pool scheduler.
class
psycopg_pool.psycopg_pool.pool_async.ShrinkPoolIf the pool can shrink, remove one connection.
class
psycopg_pool.psycopg_pool.pool_async.StopWorkerSignal the maintenance worker to terminate.
method
psycopg_pool.psycopg_pool.pool_async.WaitingClient.set(conn:ACT) -> boolSignal the client waiting that a connection is ready.
method
psycopg_pool.psycopg_pool.pool_async.WaitingClient.wait(timeout:float) -> ACTWait for a connection to be set and return it.
method
psycopg_pool.psycopg_pool.sched.Scheduler.enter(delay:float, action:Callable[[], Any] | None) -> TaskEnter a new task in the queue delayed in the future.
method
psycopg_pool.psycopg_pool.sched.Scheduler.enterabs(time:float, action:Callable[[], Any] | None) -> TaskEnter a new task in the queue at an absolute time.
method
psycopg_pool.psycopg_pool.sched.Scheduler.run() -> NoneExecute the events scheduled.
method
psycopg_pool.psycopg_pool.sched_async.AsyncScheduler.enter(delay:float, action:Callable[[], Any] | None) -> TaskEnter a new task in the queue delayed in the future.
method
psycopg_pool.psycopg_pool.sched_async.AsyncScheduler.enterabs(time:float, action:Callable[[], Any] | None) -> TaskEnter a new task in the queue at an absolute time.
method
psycopg_pool.psycopg_pool.sched_async.AsyncScheduler.run() -> NoneExecute the events scheduled.
About this data
These signatures were extracted from the public source of psycopg/psycopg
using Python's ast module. Argument names, default values,
type annotations and return types are taken verbatim from the code.
Implementation bodies are never stored. See
how it works for details.