psycopg2cffi.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # testing/engines.py
  2. # Copyright (C) 2005-2017 the SQLAlchemy authors and contributors
  3. # <see AUTHORS file>
  4. #
  5. # This module is part of SQLAlchemy and is released under
  6. # the MIT License: http://www.opensource.org/licenses/mit-license.php
  7. """
  8. .. dialect:: postgresql+psycopg2cffi
  9. :name: psycopg2cffi
  10. :dbapi: psycopg2cffi
  11. :connectstring: \
  12. postgresql+psycopg2cffi://user:password@host:port/dbname\
  13. [?key=value&key=value...]
  14. :url: http://pypi.python.org/pypi/psycopg2cffi/
  15. ``psycopg2cffi`` is an adaptation of ``psycopg2``, using CFFI for the C
  16. layer. This makes it suitable for use in e.g. PyPy. Documentation
  17. is as per ``psycopg2``.
  18. .. versionadded:: 1.0.0
  19. .. seealso::
  20. :mod:`sqlalchemy.dialects.postgresql.psycopg2`
  21. """
  22. from .psycopg2 import PGDialect_psycopg2
  23. class PGDialect_psycopg2cffi(PGDialect_psycopg2):
  24. driver = 'psycopg2cffi'
  25. supports_unicode_statements = True
  26. # psycopg2cffi's first release is 2.5.0, but reports
  27. # __version__ as 2.4.4. Subsequent releases seem to have
  28. # fixed this.
  29. FEATURE_VERSION_MAP = dict(
  30. native_json=(2, 4, 4),
  31. native_jsonb=(2, 7, 1),
  32. sane_multi_rowcount=(2, 4, 4),
  33. array_oid=(2, 4, 4),
  34. hstore_adapter=(2, 4, 4)
  35. )
  36. @classmethod
  37. def dbapi(cls):
  38. return __import__('psycopg2cffi')
  39. @classmethod
  40. def _psycopg2_extensions(cls):
  41. root = __import__('psycopg2cffi', fromlist=['extensions'])
  42. return root.extensions
  43. @classmethod
  44. def _psycopg2_extras(cls):
  45. root = __import__('psycopg2cffi', fromlist=['extras'])
  46. return root.extras
  47. dialect = PGDialect_psycopg2cffi