Search notes:

PEP 249 - Python Database API Specification v2.0

PEP 249 specifies common usage patterns for Python packages that allow to connect to databases.

DBAPI

DBAPI is a commonly seen abbreviation that stands for Python Database API Specification.

Interfaces and objects

Module interface

apilevel Evaluates to 1.0 or 2.0
connect() Returns a Connection object
paramstyle qmark: ? | numeric: :1 | named: :name | format : name=%2 | pyformat: %(name)s
threadsafety 03

Connection object

close()
commit()
rollback()
cursor() Returns a new Cursor object

Cursor object

arraysize R/W: Number of rows fetched with fetchmany() (and also fetchall() ?)
callproc() Calls a stored procedure. If the procedure produces a resultset, it must be iterated over using fetch()
connection Optional, v2
description A sequence of 7-item (of which only the first two are mandatory) sequences describing one result column.
execute() Prepare and execute a statement. An optional second argument specifies the values that will be bound to variables in the statement (sequence or mapping).
executemany() See also arraysize
fetchall() Returns a list of tuples containing the query result set's remaining rows. Performance may be affected by value of arraysize property. See also fetchmany().
fetchmany() Fetches a given amount or arraysize records. See also fetchall()
fetchone() Returns one record as a tuple (see these SQLite examples)
lastrowid Returns the last inserted rowid.
next() Optional, v2
nextset() Skip to the next available set. (Optional as not all databases support multiple result sets)
messages Optional, v2
rowcount
rownumber Optional, v2
scroll() Optional, v2
setinputsizes(s)
setoutputsize(s[, col])
__iter__ Optional, v2: Make cursors compatible with the iterable protocol.

Exception hierarchy

StandardError
   Warning
   Error
      InterfaceError
      DatabaseError
         DataError
         OperationalError
         IntegrityError
         InternalError
         ProgrammingError
         NotSupportedError

See also

The standard library sqlite3
A small list of other interesting PEPs
The Python libraries

Links

https://peps.python.org/pep-0249/

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758204091, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/Python/PEP/0249(120): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78