pydoc > pgdb

📛 NAME

pgdb – DB-API 2.0 compliant module for PyGreSQL.

🚀 Quick Reference

Use CaseCommandDescription
🔌 Connectpgdb.connect(dsn, user, password, host, database)Open a database connection
đŸ–Šī¸ Cursorconnection.cursor()Create a new cursor object
⚡ Executecursor.execute(query, params)Execute a query with optional dictionary params
⚡ Execute Manycursor.executemany(query, param_list)Execute query with each param dict in list
âŦ‡ī¸ Fetch Onecursor.fetchone()Fetch a single row as a list
âŦ‡ī¸ Fetch Allcursor.fetchall()Fetch all remaining rows
âŦ‡ī¸ Fetch Manycursor.fetchmany([size])Fetch up to size rows (default arraysize=1)
📊 Row Countcursor.rowcountNumber of rows in result set (after execute)
📋 Descriptioncursor.descriptionList of column info tuples
✅ Commitconnection.commit()Commit pending transaction
â†Šī¸ Rollbackconnection.rollback()Roll back pending transaction
❌ Close Cursorcursor.close()Close the cursor
❌ Close Connectionconnection.close()Close the database connection

📖 DESCRIPTION

(c) 1999, Pascal Andre <andre AT via.fr>. See package documentation for further copyright information.

Inline documentation is sparse. See DB-API 2.0 specification: http://www.python.org/peps/pep-0249.html

Basic usage:

pgdb.connect(connect_string) # open a connection
# connect_string = 'host:database:user:password:opt'
# All parts are optional. You may also pass host through
# password as keyword arguments. To pass a port,
# pass it in the host keyword parameter:
connection = pgdb.connect(host='localhost:5432')

cursor = connection.cursor() # open a cursor

cursor.execute(query[, params])
# Execute a query, binding params (a dictionary) if they are
# passed. The binding syntax is the same as the % operator
# for dictionaries, and no quoting is done.

cursor.executemany(query, list of params)
# Execute a query many times, binding each param dictionary
# from the list.

cursor.fetchone() # fetch one row, [value, value, ...]

cursor.fetchall() # fetch all rows, [[value, value, ...], ...]

cursor.fetchmany([size])
# returns size or cursor.arraysize number of rows,
# [[value, value, ...], ...] from result set.
# Default cursor.arraysize is 1.

cursor.description # returns information about the columns
#   [(column_name, type_name, display_size,
#           internal_size, precision, scale, null_ok), ...]
# Note that display_size, precision, scale and null_ok
# are not implemented.

cursor.rowcount # number of rows available in the result set
# Available after a call to execute.

connection.commit() # commit transaction

connection.rollback() # or rollback transaction

cursor.close() # close the cursor

connection.close() # close the connection

đŸ“Ļ CLASSES

Exception hierarchy:

🔗 Connection

Connection(cnx) – Connection object.

Exception attributes available on the connection:

đŸŽ¯ Cursor

Cursor(dbcnx) – Cursor object.

đŸ—‚ī¸ Binary

Binary – Inherits from builtins.bytes. Construct an object capable of holding a binary (long) string value. Inherits all methods of bytes.

📋 Hstore

Hstore – Inherits from builtins.dict. Wrapper class for marking hstore values.

📄 Json

Json(obj, encode=None) – Construct a wrapper for holding an object serializable to JSON.

đŸ’Ŧ Literal

Literal(sql) – Construct a wrapper for holding a literal SQL string.

🧩 Type

Type(values) – Inherits from builtins.frozenset. Type class for PostgreSQL data types; types are dynamic so type names are used as internal codes.

🆔 Uuid

Uuid = uuid.UUID – Represents UUIDs per RFC 4122. Immutable, hashable, usable as dict keys.

Constructors: hex, bytes, bytes_le, fields, int. Read-only attributes: hex, int, bytes, bytes_le, fields, time_low, time_mid, time_hi_version, clock_seq_hi_variant, clock_seq_low, node, time, clock_seq, urn, variant, version, is_safe.

âš ī¸ Error

Base exception for all pgdb errors. Inherits from builtins.Exception.

🐞 DatabaseError

MRO: DatabaseError → Error → Exception. Inherits all methods.

đŸ”ĸ DataError

MRO: DataError → DatabaseError → Error → Exception. Inherits all methods.

🔐 IntegrityError

MRO: IntegrityError → DatabaseError → Error → Exception. Inherits all methods.

🔌 InterfaceError

MRO: InterfaceError → Error → Exception. Inherits all methods.

đŸšĢ NotSupportedError

MRO: NotSupportedError → DatabaseError → Error → Exception. Inherits all methods.

âš™ī¸ OperationalError

MRO: OperationalError → DatabaseError → Error → Exception. Inherits all methods.

👨‍đŸ’ģ ProgrammingError

MRO: ProgrammingError → DatabaseError → Error → Exception. Inherits all methods.

âš ī¸ Warning

MRO: Warning → Exception. Inherits all methods.

âš™ī¸ FUNCTIONS

📊 DATA

đŸ”ĸ VERSION

5.1.2

📁 FILE

/usr/lib/python3/dist-packages/pgdb.py

pgdb
📛 NAME 🚀 Quick Reference 📖 DESCRIPTION đŸ“Ļ CLASSES
🔗 Connection đŸŽ¯ Cursor đŸ—‚ī¸ Binary 📋 Hstore 📄 Json đŸ’Ŧ Literal 🧩 Type 🆔 Uuid âš ī¸ Error
âš™ī¸ FUNCTIONS 📊 DATA đŸ”ĸ VERSION 📁 FILE

Generated by phpman v4.9.27 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-18 19:11 @216.73.216.114
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format

^_top_^