summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/build/changelog/changelog_10.rst12
-rw-r--r--doc/build/changelog/migration_10.rst8
-rw-r--r--doc/build/dialects/postgresql.rst18
-rw-r--r--lib/sqlalchemy/dialects/postgresql/psycopg2cffi.py9
-rw-r--r--lib/sqlalchemy/testing/util.py4
-rw-r--r--setup.cfg2
-rw-r--r--test/dialect/postgresql/test_query.py32
-rw-r--r--test/dialect/postgresql/test_types.py4
-rw-r--r--test/engine/test_execute.py50
-rw-r--r--test/requirements.py4
10 files changed, 90 insertions, 53 deletions
diff --git a/doc/build/changelog/changelog_10.rst b/doc/build/changelog/changelog_10.rst
index 18043c456..2c3e26f2e 100644
--- a/doc/build/changelog/changelog_10.rst
+++ b/doc/build/changelog/changelog_10.rst
@@ -23,6 +23,18 @@
on compatibility concerns, see :doc:`/changelog/migration_10`.
.. change::
+ :tags: feature, postgresql, pypy
+ :tickets: 3052
+ :pullreq: bitbucket:34
+
+ Added support for the psycopg2cffi DBAPI on pypy. Pull request
+ courtesy shauns.
+
+ .. seealso::
+
+ :mod:`sqlalchemy.dialects.postgresql.psycopg2cffi`
+
+ .. change::
:tags: feature, orm
:tickets: 3262
:pullreq: bitbucket:38
diff --git a/doc/build/changelog/migration_10.rst b/doc/build/changelog/migration_10.rst
index c0369d8b8..23ee6f466 100644
--- a/doc/build/changelog/migration_10.rst
+++ b/doc/build/changelog/migration_10.rst
@@ -1769,6 +1769,14 @@ by Postgresql as of 9.4. SQLAlchemy allows this using
:class:`.FunctionFilter`
+Support for psycopg2cffi Dialect on Pypy
+----------------------------------------
+
+Support for the pypy psycopg2cffi dialect is added.
+
+.. seealso::
+
+ :mod:`sqlalchemy.dialects.postgresql.psycopg2cffi`
Dialect Improvements and Changes - MySQL
=============================================
diff --git a/doc/build/dialects/postgresql.rst b/doc/build/dialects/postgresql.rst
index 11bbe2cf9..e5d8d51bc 100644
--- a/doc/build/dialects/postgresql.rst
+++ b/doc/build/dialects/postgresql.rst
@@ -188,22 +188,24 @@ psycopg2
.. automodule:: sqlalchemy.dialects.postgresql.psycopg2
+pg8000
+--------------
+
+.. automodule:: sqlalchemy.dialects.postgresql.pg8000
+
+psycopg2cffi
+--------------
+
+.. automodule:: sqlalchemy.dialects.postgresql.psycopg2cffi
+
py-postgresql
--------------------
.. automodule:: sqlalchemy.dialects.postgresql.pypostgresql
-pg8000
---------------
-
-.. automodule:: sqlalchemy.dialects.postgresql.pg8000
zxjdbc
--------------
.. automodule:: sqlalchemy.dialects.postgresql.zxjdbc
-psycopg2cffi
---------------
-
-.. automodule:: sqlalchemy.dialects.postgresql.psycopg2cffi
diff --git a/lib/sqlalchemy/dialects/postgresql/psycopg2cffi.py b/lib/sqlalchemy/dialects/postgresql/psycopg2cffi.py
index 5217c5561..f5c475d90 100644
--- a/lib/sqlalchemy/dialects/postgresql/psycopg2cffi.py
+++ b/lib/sqlalchemy/dialects/postgresql/psycopg2cffi.py
@@ -1,5 +1,5 @@
# testing/engines.py
-# Copyright (C) 2005-2014 the SQLAlchemy authors and contributors
+# Copyright (C) 2005-2015 the SQLAlchemy authors and contributors
# <see AUTHORS file>
#
# This module is part of SQLAlchemy and is released under
@@ -13,9 +13,11 @@ postgresql+psycopg2cffi://user:password@host:port/dbname\
[?key=value&key=value...]
:url: http://pypi.python.org/pypi/psycopg2cffi/
-`psycopg2cffi` is an adaptation of `psycopg2`, using CFFI for the C
+``psycopg2cffi`` is an adaptation of ``psycopg2``, using CFFI for the C
layer. This makes it suitable for use in e.g. PyPy. Documentation
-is as per `psycopg2`.
+is as per ``psycopg2``.
+
+.. versionadded:: 1.0.0
.. seealso::
@@ -27,6 +29,7 @@ from .psycopg2 import PGDialect_psycopg2
class PGDialect_psycopg2cffi(PGDialect_psycopg2):
driver = 'psycopg2cffi'
+ supports_unicode_statements = True
@classmethod
def dbapi(cls):
diff --git a/lib/sqlalchemy/testing/util.py b/lib/sqlalchemy/testing/util.py
index eea39b1f7..8230f923a 100644
--- a/lib/sqlalchemy/testing/util.py
+++ b/lib/sqlalchemy/testing/util.py
@@ -147,6 +147,10 @@ def run_as_contextmanager(ctx, fn, *arg, **kw):
simulating the behavior of 'with' to support older
Python versions.
+ This is not necessary anymore as we have placed 2.6
+ as minimum Python version, however some tests are still using
+ this structure.
+
"""
obj = ctx.__enter__()
diff --git a/setup.cfg b/setup.cfg
index 5eb35469f..dc10877f7 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -42,7 +42,7 @@ postgresql=postgresql://scott:tiger@127.0.0.1:5432/test
pg8000=postgresql+pg8000://scott:tiger@127.0.0.1:5432/test
postgres=postgresql://scott:tiger@127.0.0.1:5432/test
postgresql_jython=postgresql+zxjdbc://scott:tiger@127.0.0.1:5432/test
-postgresql_psycopg2cffi=postgresql+psycopg2cffi://127.0.0.1:5432/test
+postgresql_psycopg2cffi=postgresql+psycopg2cffi://scott:tiger@127.0.0.1:5432/test
mysql=mysql://scott:tiger@127.0.0.1:3306/test
mysqlconnector=mysql+mysqlconnector://scott:tiger@127.0.0.1:3306/test
mssql=mssql+pyodbc://scott:tiger@ms_2008
diff --git a/test/dialect/postgresql/test_query.py b/test/dialect/postgresql/test_query.py
index 73319438d..27cb958fd 100644
--- a/test/dialect/postgresql/test_query.py
+++ b/test/dialect/postgresql/test_query.py
@@ -856,21 +856,23 @@ class ExtractTest(fixtures.TablesTest):
def utcoffset(self, dt):
return datetime.timedelta(hours=4)
- conn = testing.db.connect()
-
- # we aren't resetting this at the moment but we don't have
- # any other tests that are TZ specific
- conn.execute("SET SESSION TIME ZONE 0")
- conn.execute(
- cls.tables.t.insert(),
- {
- 'dtme': datetime.datetime(2012, 5, 10, 12, 15, 25),
- 'dt': datetime.date(2012, 5, 10),
- 'tm': datetime.time(12, 15, 25),
- 'intv': datetime.timedelta(seconds=570),
- 'dttz': datetime.datetime(2012, 5, 10, 12, 15, 25, tzinfo=TZ())
- },
- )
+ with testing.db.connect() as conn:
+
+ # we aren't resetting this at the moment but we don't have
+ # any other tests that are TZ specific
+ conn.execute("SET SESSION TIME ZONE 0")
+ conn.execute(
+ cls.tables.t.insert(),
+ {
+ 'dtme': datetime.datetime(2012, 5, 10, 12, 15, 25),
+ 'dt': datetime.date(2012, 5, 10),
+ 'tm': datetime.time(12, 15, 25),
+ 'intv': datetime.timedelta(seconds=570),
+ 'dttz':
+ datetime.datetime(2012, 5, 10, 12, 15, 25,
+ tzinfo=TZ())
+ },
+ )
def _test(self, expr, field="all", overrides=None):
t = self.tables.t
diff --git a/test/dialect/postgresql/test_types.py b/test/dialect/postgresql/test_types.py
index 95c034f11..1f572c9a1 100644
--- a/test/dialect/postgresql/test_types.py
+++ b/test/dialect/postgresql/test_types.py
@@ -1399,7 +1399,7 @@ class HStoreRoundTripTest(fixtures.TablesTest):
use_native_hstore=False))
else:
engine = testing.db
- engine.connect()
+ engine.connect().close()
return engine
def test_reflect(self):
@@ -2031,7 +2031,7 @@ class JSONRoundTripTest(fixtures.TablesTest):
engine = engines.testing_engine(options=options)
else:
engine = testing.db
- engine.connect()
+ engine.connect().close()
return engine
def test_reflect(self):
diff --git a/test/engine/test_execute.py b/test/engine/test_execute.py
index b5b414af2..730ef4446 100644
--- a/test/engine/test_execute.py
+++ b/test/engine/test_execute.py
@@ -639,21 +639,21 @@ class ConvenienceExecuteTest(fixtures.TablesTest):
def test_transaction_connection_ctx_commit(self):
fn = self._trans_fn(True)
- conn = testing.db.connect()
- ctx = conn.begin()
- testing.run_as_contextmanager(ctx, fn, 5, value=8)
- self._assert_fn(5, value=8)
+ with testing.db.connect() as conn:
+ ctx = conn.begin()
+ testing.run_as_contextmanager(ctx, fn, 5, value=8)
+ self._assert_fn(5, value=8)
def test_transaction_connection_ctx_rollback(self):
fn = self._trans_rollback_fn(True)
- conn = testing.db.connect()
- ctx = conn.begin()
- assert_raises_message(
- Exception,
- "breakage",
- testing.run_as_contextmanager, ctx, fn, 5, value=8
- )
- self._assert_no_data()
+ with testing.db.connect() as conn:
+ ctx = conn.begin()
+ assert_raises_message(
+ Exception,
+ "breakage",
+ testing.run_as_contextmanager, ctx, fn, 5, value=8
+ )
+ self._assert_no_data()
def test_connection_as_ctx(self):
fn = self._trans_fn()
@@ -666,10 +666,12 @@ class ConvenienceExecuteTest(fixtures.TablesTest):
def test_connect_as_ctx_noautocommit(self):
fn = self._trans_fn()
self._assert_no_data()
- ctx = testing.db.connect().execution_options(autocommit=False)
- testing.run_as_contextmanager(ctx, fn, 5, value=8)
- # autocommit is off
- self._assert_no_data()
+
+ with testing.db.connect() as conn:
+ ctx = conn.execution_options(autocommit=False)
+ testing.run_as_contextmanager(ctx, fn, 5, value=8)
+ # autocommit is off
+ self._assert_no_data()
def test_transaction_engine_fn_commit(self):
fn = self._trans_fn()
@@ -687,17 +689,17 @@ class ConvenienceExecuteTest(fixtures.TablesTest):
def test_transaction_connection_fn_commit(self):
fn = self._trans_fn()
- conn = testing.db.connect()
- conn.transaction(fn, 5, value=8)
- self._assert_fn(5, value=8)
+ with testing.db.connect() as conn:
+ conn.transaction(fn, 5, value=8)
+ self._assert_fn(5, value=8)
def test_transaction_connection_fn_rollback(self):
fn = self._trans_rollback_fn()
- conn = testing.db.connect()
- assert_raises(
- Exception,
- conn.transaction, fn, 5, value=8
- )
+ with testing.db.connect() as conn:
+ assert_raises(
+ Exception,
+ conn.transaction, fn, 5, value=8
+ )
self._assert_no_data()
diff --git a/test/requirements.py b/test/requirements.py
index 6b8ba504c..89fc108b9 100644
--- a/test/requirements.py
+++ b/test/requirements.py
@@ -656,6 +656,10 @@ class DefaultRequirements(SuiteRequirements):
'postgresql+pg8000', None, None,
'postgresql+pg8000 has FP inaccuracy even with '
'only four decimal places '),
+ (
+ 'postgresql+psycopg2cffi', None, None,
+ 'postgresql+psycopg2cffi has FP inaccuracy even with '
+ 'only four decimal places '),
])
@property