Markdown Format | JSON API | MCP Server Tool
Help on package psycopg2: NAME psycopg2 - A Python driver for PostgreSQL DESCRIPTION psycopg is a PostgreSQL_ database adapter for the Python_ programming language. This is version 2, a complete rewrite of the original code to provide new-style classes for connection and cursor objects and other sweet candies. Like the original, psycopg 2 was written with the aim of being very small and fast, and stable as a rock. Homepage: https://psycopg.org/ .. _PostgreSQL: https://www.postgresql.org/ .. _Python: https://www.python.org/ :Groups: * `Connections creation`: connect * `Value objects constructors`: Binary, Date, DateFromTicks, Time, TimeFromTicks, Timestamp, TimestampFromTicks PACKAGE CONTENTS _ipaddress _json _psycopg _range errorcodes errors extensions extras pool sql tz SUBMODULES _ext CLASSES builtins.Exception(builtins.BaseException) Error DatabaseError DataError IntegrityError InternalError NotSupportedError OperationalError ProgrammingError InterfaceError Warning class DataError(DatabaseError) | Error related to problems with the processed data. | | Method resolution order: | DataError | DatabaseError | Error | builtins.Exception | builtins.BaseException | builtins.object | | Data descriptors inherited from DatabaseError: | | __weakref__ | list of weak references to the object (if defined) | | ---------------------------------------------------------------------- | Methods inherited from Error: | | __init__(self, /, *args, **kwargs) | Initialize self. See help(type(self)) for accurate signature. | | __reduce__(...) | Helper for pickle. | | __setstate__(...) | | ---------------------------------------------------------------------- | Static methods inherited from Error: | | __new__(*args, **kwargs) from builtins.type | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors inherited from Error: | | cursor | The cursor that raised the exception, if available, else None | | diag | A Diagnostics object to get further information about the error | | pgcode | The error code returned by the backend, if available, else None | | pgerror | The error message returned by the backend, if available, else None | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __delattr__(self, name, /) | Implement delattr(self, name). | | __getattribute__(self, name, /) | Return getattr(self, name). | | __repr__(self, /) | Return repr(self). | | __setattr__(self, name, value, /) | Implement setattr(self, name, value). | | __str__(self, /) | Return str(self). | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args class DatabaseError(Error) | Error related to the database engine. | | Method resolution order: | DatabaseError | Error | builtins.Exception | builtins.BaseException | builtins.object | | Data descriptors defined here: | | __weakref__ | list of weak references to the object (if defined) | | ---------------------------------------------------------------------- | Methods inherited from Error: | | __init__(self, /, *args, **kwargs) | Initialize self. See help(type(self)) for accurate signature. | | __reduce__(...) | Helper for pickle. | | __setstate__(...) | | ---------------------------------------------------------------------- | Static methods inherited from Error: | | __new__(*args, **kwargs) from builtins.type | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors inherited from Error: | | cursor | The cursor that raised the exception, if available, else None | | diag | A Diagnostics object to get further information about the error | | pgcode | The error code returned by the backend, if available, else None | | pgerror | The error message returned by the backend, if available, else None | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __delattr__(self, name, /) | Implement delattr(self, name). | | __getattribute__(self, name, /) | Return getattr(self, name). | | __repr__(self, /) | Return repr(self). | | __setattr__(self, name, value, /) | Implement setattr(self, name, value). | | __str__(self, /) | Return str(self). | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args class Error(builtins.Exception) | Base class for error exceptions. | | Method resolution order: | Error | builtins.Exception | builtins.BaseException | builtins.object | | Methods defined here: | | __init__(self, /, *args, **kwargs) | Initialize self. See help(type(self)) for accurate signature. | | __reduce__(...) | Helper for pickle. | | __setstate__(...) | | ---------------------------------------------------------------------- | Static methods defined here: | | __new__(*args, **kwargs) from builtins.type | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | cursor | The cursor that raised the exception, if available, else None | | diag | A Diagnostics object to get further information about the error | | pgcode | The error code returned by the backend, if available, else None | | pgerror | The error message returned by the backend, if available, else None | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __delattr__(self, name, /) | Implement delattr(self, name). | | __getattribute__(self, name, /) | Return getattr(self, name). | | __repr__(self, /) | Return repr(self). | | __setattr__(self, name, value, /) | Implement setattr(self, name, value). | | __str__(self, /) | Return str(self). | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args class IntegrityError(DatabaseError) | Error related to database integrity. | | Method resolution order: | IntegrityError | DatabaseError | Error | builtins.Exception | builtins.BaseException | builtins.object | | Data descriptors inherited from DatabaseError: | | __weakref__ | list of weak references to the object (if defined) | | ---------------------------------------------------------------------- | Methods inherited from Error: | | __init__(self, /, *args, **kwargs) | Initialize self. See help(type(self)) for accurate signature. | | __reduce__(...) | Helper for pickle. | | __setstate__(...) | | ---------------------------------------------------------------------- | Static methods inherited from Error: | | __new__(*args, **kwargs) from builtins.type | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors inherited from Error: | | cursor | The cursor that raised the exception, if available, else None | | diag | A Diagnostics object to get further information about the error | | pgcode | The error code returned by the backend, if available, else None | | pgerror | The error message returned by the backend, if available, else None | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __delattr__(self, name, /) | Implement delattr(self, name). | | __getattribute__(self, name, /) | Return getattr(self, name). | | __repr__(self, /) | Return repr(self). | | __setattr__(self, name, value, /) | Implement setattr(self, name, value). | | __str__(self, /) | Return str(self). | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args class InterfaceError(Error) | Error related to the database interface. | | Method resolution order: | InterfaceError | Error | builtins.Exception | builtins.BaseException | builtins.object | | Data descriptors defined here: | | __weakref__ | list of weak references to the object (if defined) | | ---------------------------------------------------------------------- | Methods inherited from Error: | | __init__(self, /, *args, **kwargs) | Initialize self. See help(type(self)) for accurate signature. | | __reduce__(...) | Helper for pickle. | | __setstate__(...) | | ---------------------------------------------------------------------- | Static methods inherited from Error: | | __new__(*args, **kwargs) from builtins.type | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors inherited from Error: | | cursor | The cursor that raised the exception, if available, else None | | diag | A Diagnostics object to get further information about the error | | pgcode | The error code returned by the backend, if available, else None | | pgerror | The error message returned by the backend, if available, else None | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __delattr__(self, name, /) | Implement delattr(self, name). | | __getattribute__(self, name, /) | Return getattr(self, name). | | __repr__(self, /) | Return repr(self). | | __setattr__(self, name, value, /) | Implement setattr(self, name, value). | | __str__(self, /) | Return str(self). | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args class InternalError(DatabaseError) | The database encountered an internal error. | | Method resolution order: | InternalError | DatabaseError | Error | builtins.Exception | builtins.BaseException | builtins.object | | Data descriptors inherited from DatabaseError: | | __weakref__ | list of weak references to the object (if defined) | | ---------------------------------------------------------------------- | Methods inherited from Error: | | __init__(self, /, *args, **kwargs) | Initialize self. See help(type(self)) for accurate signature. | | __reduce__(...) | Helper for pickle. | | __setstate__(...) | | ---------------------------------------------------------------------- | Static methods inherited from Error: | | __new__(*args, **kwargs) from builtins.type | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors inherited from Error: | | cursor | The cursor that raised the exception, if available, else None | | diag | A Diagnostics object to get further information about the error | | pgcode | The error code returned by the backend, if available, else None | | pgerror | The error message returned by the backend, if available, else None | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __delattr__(self, name, /) | Implement delattr(self, name). | | __getattribute__(self, name, /) | Return getattr(self, name). | | __repr__(self, /) | Return repr(self). | | __setattr__(self, name, value, /) | Implement setattr(self, name, value). | | __str__(self, /) | Return str(self). | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args class NotSupportedError(DatabaseError) | A method or database API was used which is not supported by the database. | | Method resolution order: | NotSupportedError | DatabaseError | Error | builtins.Exception | builtins.BaseException | builtins.object | | Data descriptors inherited from DatabaseError: | | __weakref__ | list of weak references to the object (if defined) | | ---------------------------------------------------------------------- | Methods inherited from Error: | | __init__(self, /, *args, **kwargs) | Initialize self. See help(type(self)) for accurate signature. | | __reduce__(...) | Helper for pickle. | | __setstate__(...) | | ---------------------------------------------------------------------- | Static methods inherited from Error: | | __new__(*args, **kwargs) from builtins.type | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors inherited from Error: | | cursor | The cursor that raised the exception, if available, else None | | diag | A Diagnostics object to get further information about the error | | pgcode | The error code returned by the backend, if available, else None | | pgerror | The error message returned by the backend, if available, else None | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __delattr__(self, name, /) | Implement delattr(self, name). | | __getattribute__(self, name, /) | Return getattr(self, name). | | __repr__(self, /) | Return repr(self). | | __setattr__(self, name, value, /) | Implement setattr(self, name, value). | | __str__(self, /) | Return str(self). | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args class OperationalError(DatabaseError) | Error related to database operation (disconnect, memory allocation etc). | | Method resolution order: | OperationalError | DatabaseError | Error | builtins.Exception | builtins.BaseException | builtins.object | | Data descriptors inherited from DatabaseError: | | __weakref__ | list of weak references to the object (if defined) | | ---------------------------------------------------------------------- | Methods inherited from Error: | | __init__(self, /, *args, **kwargs) | Initialize self. See help(type(self)) for accurate signature. | | __reduce__(...) | Helper for pickle. | | __setstate__(...) | | ---------------------------------------------------------------------- | Static methods inherited from Error: | | __new__(*args, **kwargs) from builtins.type | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors inherited from Error: | | cursor | The cursor that raised the exception, if available, else None | | diag | A Diagnostics object to get further information about the error | | pgcode | The error code returned by the backend, if available, else None | | pgerror | The error message returned by the backend, if available, else None | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __delattr__(self, name, /) | Implement delattr(self, name). | | __getattribute__(self, name, /) | Return getattr(self, name). | | __repr__(self, /) | Return repr(self). | | __setattr__(self, name, value, /) | Implement setattr(self, name, value). | | __str__(self, /) | Return str(self). | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args class ProgrammingError(DatabaseError) | Error related to database programming (SQL error, table not found etc). | | Method resolution order: | ProgrammingError | DatabaseError | Error | builtins.Exception | builtins.BaseException | builtins.object | | Data descriptors inherited from DatabaseError: | | __weakref__ | list of weak references to the object (if defined) | | ---------------------------------------------------------------------- | Methods inherited from Error: | | __init__(self, /, *args, **kwargs) | Initialize self. See help(type(self)) for accurate signature. | | __reduce__(...) | Helper for pickle. | | __setstate__(...) | | ---------------------------------------------------------------------- | Static methods inherited from Error: | | __new__(*args, **kwargs) from builtins.type | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors inherited from Error: | | cursor | The cursor that raised the exception, if available, else None | | diag | A Diagnostics object to get further information about the error | | pgcode | The error code returned by the backend, if available, else None | | pgerror | The error message returned by the backend, if available, else None | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __delattr__(self, name, /) | Implement delattr(self, name). | | __getattribute__(self, name, /) | Return getattr(self, name). | | __repr__(self, /) | Return repr(self). | | __setattr__(self, name, value, /) | Implement setattr(self, name, value). | | __str__(self, /) | Return str(self). | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args class Warning(builtins.Exception) | A database warning. | | Method resolution order: | Warning | builtins.Exception | builtins.BaseException | builtins.object | | Data descriptors defined here: | | __weakref__ | list of weak references to the object (if defined) | | ---------------------------------------------------------------------- | Methods inherited from builtins.Exception: | | __init__(self, /, *args, **kwargs) | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Static methods inherited from builtins.Exception: | | __new__(*args, **kwargs) from builtins.type | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __delattr__(self, name, /) | Implement delattr(self, name). | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setattr__(self, name, value, /) | Implement setattr(self, name, value). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args FUNCTIONS Date(...) Date(year, month, day) -> new date Build an object holding a date value. DateFromTicks(...) DateFromTicks(ticks) -> new date Build an object holding a date value from the given ticks value. Ticks are the number of seconds since the epoch; see the documentation of the standard Python time module for details). Time(...) Time(hour, minutes, seconds, tzinfo=None) -> new time Build an object holding a time value. TimeFromTicks(...) TimeFromTicks(ticks) -> new time Build an object holding a time value from the given ticks value. Ticks are the number of seconds since the epoch; see the documentation of the standard Python time module for details). Timestamp(...) Timestamp(year, month, day, hour, minutes, seconds, tzinfo=None) -> new timestamp Build an object holding a timestamp value. TimestampFromTicks(...) TimestampFromTicks(ticks) -> new timestamp Build an object holding a timestamp value from the given ticks value. Ticks are the number of seconds since the epoch; see the documentation of the standard Python time module for details). connect(dsn=None, connection_factory=None, cursor_factory=None, **kwargs) Create a new database connection. The connection parameters can be specified as a string: conn = psycopg2.connect("dbname=test user=postgres password=secret") or using a set of keyword arguments: conn = psycopg2.connect(database="test", user="postgres", password="secret") Or as a mix of both. The basic connection parameters are: - *dbname*: the database name - *database*: the database name (only as keyword argument) - *user*: user name used to authenticate - *password*: password used to authenticate - *host*: database host address (defaults to UNIX socket if not provided) - *port*: connection port number (defaults to 5432 if not provided) Using the *connection_factory* parameter a different class or connections factory can be specified. It should be a callable object taking a dsn argument. Using the *cursor_factory* parameter, a new default cursor factory will be used by cursor(). Using *async*=True an asynchronous connection will be created. *async_* is a valid alias (for Python versions where ``async`` is a keyword). Any other keyword parameter will be passed to the underlying client library: the list of supported parameters depends on the library version. DATA BINARY = <psycopg2._psycopg.type 'BINARY'> DATETIME = <psycopg2._psycopg.type 'DATETIME'> NUMBER = <psycopg2._psycopg.type 'NUMBER'> ROWID = <psycopg2._psycopg.type 'ROWID'> STRING = <psycopg2._psycopg.type 'STRING'> __libpq_version__ = 140002 apilevel = '2.0' paramstyle = 'pyformat' threadsafety = 2 VERSION 2.9.2 (dt dec pq3 ext lo64) FILE /usr/lib/python3/dist-packages/psycopg2/__init__.py
Generated by phpMan Author: Che Dong Under GNU General Public License
2026-06-02 05:15 @216.73.216.198 CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)