Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/sqlalchemy/dialects/postgresql/psycopg2cffi.py: 71%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

21 statements  

1# dialects/postgresql/psycopg2cffi.py 

2# Copyright (C) 2005-2025 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: https://www.opensource.org/licenses/mit-license.php 

7# mypy: ignore-errors 

8 

9r""" 

10.. dialect:: postgresql+psycopg2cffi 

11 :name: psycopg2cffi 

12 :dbapi: psycopg2cffi 

13 :connectstring: postgresql+psycopg2cffi://user:password@host:port/dbname[?key=value&key=value...] 

14 :url: https://pypi.org/project/psycopg2cffi/ 

15 

16``psycopg2cffi`` is an adaptation of ``psycopg2``, using CFFI for the C 

17layer. This makes it suitable for use in e.g. PyPy. Documentation 

18is as per ``psycopg2``. 

19 

20.. seealso:: 

21 

22 :mod:`sqlalchemy.dialects.postgresql.psycopg2` 

23 

24""" # noqa 

25from .psycopg2 import PGDialect_psycopg2 

26from ... import util 

27 

28 

29class PGDialect_psycopg2cffi(PGDialect_psycopg2): 

30 driver = "psycopg2cffi" 

31 supports_unicode_statements = True 

32 supports_statement_cache = True 

33 

34 # psycopg2cffi's first release is 2.5.0, but reports 

35 # __version__ as 2.4.4. Subsequent releases seem to have 

36 # fixed this. 

37 

38 FEATURE_VERSION_MAP = dict( 

39 native_json=(2, 4, 4), 

40 native_jsonb=(2, 7, 1), 

41 sane_multi_rowcount=(2, 4, 4), 

42 array_oid=(2, 4, 4), 

43 hstore_adapter=(2, 4, 4), 

44 ) 

45 

46 @classmethod 

47 def import_dbapi(cls): 

48 return __import__("psycopg2cffi") 

49 

50 @util.memoized_property 

51 def _psycopg2_extensions(cls): 

52 root = __import__("psycopg2cffi", fromlist=["extensions"]) 

53 return root.extensions 

54 

55 @util.memoized_property 

56 def _psycopg2_extras(cls): 

57 root = __import__("psycopg2cffi", fromlist=["extras"]) 

58 return root.extras 

59 

60 

61dialect = PGDialect_psycopg2cffi