series as well. For changes that are specific to 1.0 with an emphasis
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
: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
=============================================
.. 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
# 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
[?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::
class PGDialect_psycopg2cffi(PGDialect_psycopg2):
driver = 'psycopg2cffi'
+ supports_unicode_statements = True
@classmethod
def dbapi(cls):
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__()
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
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
use_native_hstore=False))
else:
engine = testing.db
- engine.connect()
+ engine.connect().close()
return engine
def test_reflect(self):
engine = engines.testing_engine(options=options)
else:
engine = testing.db
- engine.connect()
+ engine.connect().close()
return engine
def test_reflect(self):
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()
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()
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()
'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