1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203
|
.. image:: https://travis-ci.org/chtd/psycopg2cffi.svg?branch=master
:target: https://travis-ci.org/chtd/psycopg2cffi
.. contents::
An implementation of the psycopg2 module using cffi.
The module is currently compatible with Psycopg 2.5.
Installation
------------
You can install ``psycopg2cffi`` from PyPI::
pip install psycopg2cffi
Or from source::
python setup.py install
Installation requirements are the same as for ``psycopg2`` - you must
have ``libpq`` headers, ``pg_config`` somewhere on your ``$PATH``,
Python development headers (``python-dev`` or similar), and ``ffi-dev``
for ``cffi``.
Installation was tested on Ubuntu 12.04, Ubuntu 14.04, CentOS (RHEL 5.0),
OS X 10.8 - 10.10.
It should be possible to make it work on Windows, but I did not test it.
This module works under CPython 2.7+, CPython 3.5+, PyPy 2 and PyPy 3
(PyPy version should be at least 2.0, which is ancient history now).
To use this package with Django or SQLAlchemy invoke a compatibility
hook (for example, from ``settings.py`` in case of Django, or
from a ``psycopg2.py`` file in site-packages of your virtual env)::
from psycopg2cffi import compat
compat.register()
This will map ``psycopg2cffi`` to ``psycopg2``, so now any code that
does ``import psycopg2`` will use ``psycopg2cffi``.
Submit issues to https://github.com/chtd/psycopg2cffi/issues
If you notice that ``psycopg2cffi`` under PyPy is noticeably slower than
``psycopg2`` under CPython, submit this to the issues too - it should
not be the case.
This is a port of (Michael van Tellingen port
https://github.com/mvantellingen/psycopg2-ctypes
of Alex Gaynor's RPython port
(https://bitbucket.org/alex_gaynor/pypy-postgresql/overview) of psycopg2 to
Python + ctypes) to cffi.
The main motivation for a port was speed - the writeup with benchmarks
is here: http://chtd.ru/blog/bystraya-rabota-s-postgres-pod-pypy/?lang=en
Development
-----------
To run tests, install ``pytest`` and run them with::
py.test psycopg2cffi
Note that for ``cffi>=1.0`` you need to run ``python setup.py develop``
to rebuild ``_libpq.so`` (if you changed bindings).
And for ``cffi<1.0`` (only PyPy 2.5 and below) you need to run
``python setup.py install`` once to generate ``psycopg2cffi/_config.py``,
otherwise each import will run config and notify tests will fail.
You can also run Django tests. You need to checkout Django source, add
psycopg2 compat as described above, and, from the root of the Django checkout::
PYTHONPATH=`pwd` ./tests/runtests.py \
--settings=psycopg2cffi.tests.psycopg2_tests.testconfig
In case of problems with Django tests, see official Django docs
https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/unit-tests/#running-the-unit-tests
Release notes
-------------
2.9.0 (27 Jan 2021)
+++++++++++++++++++
New features:
- Add execute_batch and execute_values to psycopg2cffi.extras by @fake-name in #98
- psycopg2cffi.extras: add fetch argument to execute_values() by @intelfx in #119
Bug fixes:
- Fix for async keyword argument when creating a connection by @donalm in #104
- Allow adapters to be passed as arguments of cursor's execute() by @amigrave in #107
- Fix installation with old cffi by dand-oss in #116
Test changes:
- Dropped support for python 2.6, 3.3, 3.4 by @thedrow in #109
- Added support for python 3.8 by @thedrow in #108
2.8.1 (31 July 2018)
++++++++++++++++++++
Release date added
2.8.0 (31 July 2018)
++++++++++++++++++++
Python 3.7 support by unimariJo (#92) and farrokhi (#101).
``async_`` should be used instead of ``async`` in public APIs
(but the change is backwards compatible,
``async`` is still supported as an alias).
2.7.7 (13 November 2017)
++++++++++++++++++++++++
Bugfixes:
- Support installation under Postgres 10 by jimbattin (#90)
2.7.6 (11 August 2017)
++++++++++++++++++++++
Bugfixes:
- Named cursors fix (affects newer Django) by danchr (#81)
- Python 3 fixes in extras by avanov (#83)
- Null check added in fast parser utils by malthe (#79)
2.7.5 (31 October 2016)
+++++++++++++++++++++++
Windows wheels support added by ryoyoko (#69).
Bugfixes:
- Non-ascii notice messages fixed by asterite3 (#72)
- AsIs with non-text/bytes fixed by jinty (#64)
- Silent failures in copy_from and copy_to fixed by gobbledygook88 (#62)
- Infinite recursion error fixed in errorcodes.lookup (#68)
- Typos in README fixed by PavloKapyshin (#66)
2.7.4 (01 April 2016)
+++++++++++++++++++++
Fix a regression with error handling when establishing the connection (#61)
2.7.3 (29 February 2016)
++++++++++++++++++++++++
Fix a bug with non-ascii error messages (#56)
2.7.2 (06 August 2015)
++++++++++++++++++++++
Fixes for FreeBSD support by Andrew Coleman
2.7.1 (20 June 2015)
++++++++++++++++++++
JSONB support
2.7.0 (21 May 2015)
+++++++++++++++++++
Use cffi 1.0, which makes installation more robust, and import is faster.
cffi<1.0 is used now only for PyPy 2.5 or below.
2.6.1 (08 Feb 2015)
+++++++++++++++++++
Fixing things that were broken in 2.6.0:
- Fix issue #31 - bigint on 32-bit
- Fix issue #32 - register_type and unicode
2.6.0 (24 Jan 2015)
+++++++++++++++++++
- Python 3 support
- A bit faster reading of int, long, float, double fields
2.5.1 (14 May 2014)
+++++++++++++++++++
- Small bugfixes
2.5.0 (3 Sep 2013)
++++++++++++++++++
- Bugfixes and a lot of compatibility work by Daniele Varrazzo
Older releases lack release notes, first release of psycopg2cffi around Nov 2012.
|