Ejemplo n.º 1
0
    def test_mro_required(self):
        import psycopg2ct
        from psycopg2ct.extensions import adapt, register_adapter, AsIs

        # Intentionally old-style, they don't expose their MRO.
        class A:
            pass
        class B(A):
            pass

        register_adapter(A, lambda a: AsIs("a"))
        with self.assertRaises(psycopg2ct.ProgrammingError):
            adapt(B())
Ejemplo n.º 2
0
    def test_adapt_most_specific(self):
        from psycopg2ct.extensions import adapt, register_adapter, AsIs

        class A(object):
            pass
        class B(A):
            pass
        class C(B):
            pass

        register_adapter(A, lambda a: AsIs("a"))
        register_adapter(B, lambda b: AsIs("b"))
        assert adapt(C()).getquoted() == "b"
Ejemplo n.º 3
0
from psycopg2ct import extensions
from psycopg2ct import tz
from psycopg2ct._impl.adapters import Binary, Date, Time, Timestamp
from psycopg2ct._impl.adapters import DateFromTicks, TimeFromTicks
from psycopg2ct._impl.adapters import TimestampFromTicks
from psycopg2ct._impl.connection import _connect
from psycopg2ct._impl.exceptions import *
from psycopg2ct._impl.typecasts import BINARY, DATETIME, NUMBER, ROWID, STRING

__version__ = '2.4.4'
apilevel = '2.0'
paramstyle = 'pyformat'
threadsafety = 2

import psycopg2ct.extensions as _ext
_ext.register_adapter(tuple, _ext.SQL_IN)
_ext.register_adapter(type(None), _ext.NoneAdapter)

# check for a more up-to-date version number generated at install time
try:
    from psycopg2ct._config import VERSION as __version__
except ImportError:
    pass

import re

def _param_escape(s,
        re_escape=re.compile(r"([\\'])"),
        re_space=re.compile(r'\s')):
    """
    Apply the escaping rule required by PQconnectdb
Ejemplo n.º 4
0
import datetime
from time import localtime

from psycopg2ct import extensions
from psycopg2ct import tz
from psycopg2ct._impl.adapters import Binary, Date, Time, Timestamp
from psycopg2ct._impl.adapters import DateFromTicks, TimeFromTicks
from psycopg2ct._impl.adapters import TimestampFromTicks
from psycopg2ct._impl.connection import connect
from psycopg2ct._impl.exceptions import *
from psycopg2ct._impl.typecasts import BINARY, DATETIME, NUMBER, ROWID, STRING

__version__ = '2.4'
apilevel = '2.0'
paramstyle = 'pyformat'

# TODO: psycopg2 thread safety is 2. I haven't reviewed it in the -ct
# but the lack of the word "lock" in the cursor module makes me assume
# it's not  -- piro
threadsafety = 1

import psycopg2ct.extensions as _ext
_ext.register_adapter(tuple, _ext.SQL_IN)
_ext.register_adapter(type(None), _ext.NoneAdapter)

__all__ = filter(lambda k: not k.startswith('_'), locals().keys())