1 """psycopg extensions to the DBAPI-2.0
3 This module holds all the extensions to the DBAPI-2.0 provided by psycopg.
5 - `connection` -- the new-type inheritable connection class
6 - `cursor` -- the new-type inheritable cursor class
7 - `adapt()` -- exposes the PEP-246_ compatible adapting mechanism used
8 by psycopg to adapt Python types to PostgreSQL ones
10 .. _PEP-246: http://www.python.org/peps/pep-0246.html
12 # psycopg/extensions.py - DBAPI-2.0 extensions specific to psycopg
14 # Copyright (C) 2003-2004 Federico Di Gregorio <fog@debian.org>
16 # This program is free software; you can redistribute it and/or modify
17 # it under the terms of the GNU General Public License as published by the
18 # Free Software Foundation; either version 2, or (at your option) any later
21 # This program is distributed in the hope that it will be useful, but
22 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY
23 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
26 from _psycopg import UNICODE, INTEGER, LONGINTEGER, BOOLEAN, FLOAT
27 from _psycopg import TIME, DATE, INTERVAL
29 from _psycopg import Boolean, QuotedString, AsIs
31 from _psycopg import DateFromMx, TimeFromMx, TimestampFromMx
32 from _psycopg import IntervalFromMx
36 from _psycopg import DateFromPy, TimeFromPy, TimestampFromPy
37 from _psycopg import IntervalFromPy
41 from _psycopg import adapt, adapters, encodings, connection, cursor
42 from _psycopg import string_types, binary_types, new_type, register_type
43 from _psycopg import ISQLQuote
45 """Isolation level values."""
46 ISOLATION_LEVEL_AUTOCOMMIT = 0
47 ISOLATION_LEVEL_READ_COMMITTED = 1
48 ISOLATION_LEVEL_SERIALIZABLE = 2
50 # PostgreSQL maps the the other standard values to already defined levels
51 ISOLATION_LEVEL_REPEATABLE_READ = ISOLATION_LEVEL_SERIALIZABLE
52 ISOLATION_LEVEL_READ_UNCOMMITTED = ISOLATION_LEVEL_READ_COMMITTED
54 """Transaction status values."""
61 # This is a usefull mnemonic to check if the connection is in a transaction
62 STATUS_IN_TRANSACTION = STATUS_BEGIN
65 def register_adapter(typ, callable):
66 """Register 'callable' as an ISQLQuote adapter for type 'typ'."""
67 adapters[(typ, ISQLQuote)] = callable
69 __all__ = [ k for k in locals().keys() if not k.startswith('_') ]