summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/cextension/resultproxy.c3
-rw-r--r--lib/sqlalchemy/dialects/oracle/cx_oracle.py6
-rw-r--r--lib/sqlalchemy/dialects/postgresql/base.py8
-rw-r--r--lib/sqlalchemy/dialects/postgresql/psycopg2.py3
-rw-r--r--lib/sqlalchemy/dialects/sqlite/base.py10
-rw-r--r--lib/sqlalchemy/orm/__init__.py7
-rw-r--r--lib/sqlalchemy/orm/session.py3
-rw-r--r--lib/sqlalchemy/pool.py2
-rw-r--r--lib/sqlalchemy/sql/expression.py21
-rw-r--r--lib/sqlalchemy/sql/util.py1
-rw-r--r--lib/sqlalchemy/types.py6
11 files changed, 40 insertions, 30 deletions
diff --git a/lib/sqlalchemy/cextension/resultproxy.c b/lib/sqlalchemy/cextension/resultproxy.c
index 400fd16fc..7404b9ed2 100644
--- a/lib/sqlalchemy/cextension/resultproxy.c
+++ b/lib/sqlalchemy/cextension/resultproxy.c
@@ -12,6 +12,7 @@ the MIT License: http://www.opensource.org/licenses/mit-license.php
typedef int Py_ssize_t;
#define PY_SSIZE_T_MAX INT_MAX
#define PY_SSIZE_T_MIN INT_MIN
+typedef Py_ssize_t (*lenfunc)(PyObject *);
#endif
@@ -162,7 +163,7 @@ BaseRowProxy_processvalues(PyObject *values, PyObject *processors, int astuple)
PyErr_Format(PyExc_RuntimeError,
"number of values in row (%d) differ from number of column "
"processors (%d)",
- num_values, num_processors);
+ (int)num_values, (int)num_processors);
return NULL;
}
diff --git a/lib/sqlalchemy/dialects/oracle/cx_oracle.py b/lib/sqlalchemy/dialects/oracle/cx_oracle.py
index dd6763c09..e82100872 100644
--- a/lib/sqlalchemy/dialects/oracle/cx_oracle.py
+++ b/lib/sqlalchemy/dialects/oracle/cx_oracle.py
@@ -122,6 +122,8 @@ class _LOBMixin(object):
return process
class _NativeUnicodeMixin(object):
+ # Py3K
+ #pass
# Py2K
def bind_processor(self, dialect):
if dialect._cx_oracle_with_unicode:
@@ -505,6 +507,10 @@ class OracleDialect_cx_oracle(OracleDialect):
for k, v in opts.items():
if isinstance(v, str):
opts[k] = unicode(v)
+ else:
+ for k, v in opts.items():
+ if isinstance(v, unicode):
+ opts[k] = str(v)
# end Py2K
if 'mode' in url.query:
diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py
index 7de5cafad..aa2048d4b 100644
--- a/lib/sqlalchemy/dialects/postgresql/base.py
+++ b/lib/sqlalchemy/dialects/postgresql/base.py
@@ -36,6 +36,14 @@ PostgreSQL 8.2 supports an ``INSERT...RETURNING`` syntax which SQLAlchemy suppor
as well. A future release of SQLA will use this feature by default in lieu of
sequence pre-execution in order to retrieve new primary key values, when available.
+Transaction Isolation Level
+---------------------------
+
+:func:`create_engine` accepts an ``isolation_level`` parameter which results in
+the command ``SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL <level>``
+being invoked for every new connection. Valid values for this parameter are
+``READ_COMMITTED``, ``READ_UNCOMMITTED``, ``REPEATABLE_READ``, and ``SERIALIZABLE``.
+
INSERT/UPDATE...RETURNING
-------------------------
diff --git a/lib/sqlalchemy/dialects/postgresql/psycopg2.py b/lib/sqlalchemy/dialects/postgresql/psycopg2.py
index 2a51a7239..6ae6c6c08 100644
--- a/lib/sqlalchemy/dialects/postgresql/psycopg2.py
+++ b/lib/sqlalchemy/dialects/postgresql/psycopg2.py
@@ -25,9 +25,6 @@ psycopg2-specific keyword arguments which are accepted by :func:`~sqlalchemy.cre
at a time are fetched over the wire to reduce conversational overhead.
* *use_native_unicode* - Enable the usage of Psycopg2 "native unicode" mode per connection. True
by default.
-* *isolation_level* - Sets the transaction isolation level for each transaction
- within the engine. Valid isolation levels are `READ_COMMITTED`,
- `READ_UNCOMMITTED`, `REPEATABLE_READ`, and `SERIALIZABLE`.
Transactions
------------
diff --git a/lib/sqlalchemy/dialects/sqlite/base.py b/lib/sqlalchemy/dialects/sqlite/base.py
index ca0a39136..ec3d7b8ac 100644
--- a/lib/sqlalchemy/dialects/sqlite/base.py
+++ b/lib/sqlalchemy/dialects/sqlite/base.py
@@ -41,7 +41,15 @@ to the Table construct::
Table('sometable', metadata,
Column('id', Integer, primary_key=True),
sqlite_autoincrement=True)
-
+
+Transaction Isolation Level
+---------------------------
+
+:func:`create_engine` accepts an ``isolation_level`` parameter which results in
+the command ``PRAGMA read_uncommitted <level>`` being invoked for every new
+connection. Valid values for this parameter are ``SERIALIZABLE`` and
+``READ UNCOMMITTED`` corresponding to a value of 0 and 1, respectively.
+
"""
import datetime, re, time
diff --git a/lib/sqlalchemy/orm/__init__.py b/lib/sqlalchemy/orm/__init__.py
index c2f6337bc..a262acd9f 100644
--- a/lib/sqlalchemy/orm/__init__.py
+++ b/lib/sqlalchemy/orm/__init__.py
@@ -136,13 +136,6 @@ def scoped_session(session_factory, scopefunc=None):
Session.commit()
Session.close()
- To map classes so that new instances are saved in the current Session
- automatically, as well as to provide session-aware class attributes such
- as "query", use the `mapper` classmethod from the scoped session::
-
- mapper = Session.mapper
- mapper(Class, table, ...)
-
"""
return ScopedSession(session_factory, scopefunc=scopefunc)
diff --git a/lib/sqlalchemy/orm/session.py b/lib/sqlalchemy/orm/session.py
index 7641905f0..42b1b3cb5 100644
--- a/lib/sqlalchemy/orm/session.py
+++ b/lib/sqlalchemy/orm/session.py
@@ -147,7 +147,7 @@ def sessionmaker(bind=None, class_=None, autoflush=True, autocommit=False,
twophase
When ``True``, all transactions will be started using
- :mod:~sqlalchemy.engine_TwoPhaseTransaction. During a ``commit()``, after
+ :mod:`~sqlalchemy.engine_TwoPhaseTransaction`. During a ``commit()``, after
``flush()`` has been issued for all attached databases, the
``prepare()`` method on each database's ``TwoPhaseTransaction`` will be
called. This allows each database to roll back the entire transaction,
@@ -1616,7 +1616,6 @@ def _state_session(state):
return None
# Lazy initialization to avoid circular imports
-unitofwork.object_session = object_session
unitofwork._state_session = _state_session
from sqlalchemy.orm import mapper
mapper._expire_state = _expire_state
diff --git a/lib/sqlalchemy/pool.py b/lib/sqlalchemy/pool.py
index 31ab7facc..ef1323892 100644
--- a/lib/sqlalchemy/pool.py
+++ b/lib/sqlalchemy/pool.py
@@ -454,7 +454,7 @@ class _CursorFairy(object):
ex_text = str(e)
except TypeError:
ex_text = repr(e)
- self.__parent._logger.warn("Error closing cursor: %s", ex_text)
+ self._parent._logger.warn("Error closing cursor: %s", ex_text)
if isinstance(e, (SystemExit, KeyboardInterrupt)):
raise
diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py
index 70e26cfcc..6dd9d8baf 100644
--- a/lib/sqlalchemy/sql/expression.py
+++ b/lib/sqlalchemy/sql/expression.py
@@ -34,8 +34,8 @@ from sqlalchemy.sql import operators
from sqlalchemy.sql.visitors import Visitable, cloned_traverse
import operator
-functions, schema, sql_util, sqltypes = None, None, None, None
-DefaultDialect, ClauseAdapter, Annotated = None, None, None
+functions, sql_util, sqltypes = None, None, None
+DefaultDialect = None
__all__ = [
'Alias', 'ClauseElement',
@@ -1075,10 +1075,10 @@ class ClauseElement(Visitable):
dictionary.
"""
- global Annotated
- if Annotated is None:
- from sqlalchemy.sql.util import Annotated
- return Annotated(self, values)
+ global sql_util
+ if sql_util is None:
+ from sqlalchemy.sql import util as sql_util
+ return sql_util.Annotated(self, values)
def _deannotate(self):
"""return a copy of this ClauseElement with an empty annotations
@@ -1973,10 +1973,11 @@ class FromClause(Selectable):
object, returning a copy of this :class:`FromClause`.
"""
- global ClauseAdapter
- if ClauseAdapter is None:
- from sqlalchemy.sql.util import ClauseAdapter
- return ClauseAdapter(alias).traverse(self)
+
+ global sql_util
+ if sql_util is None:
+ from sqlalchemy.sql import util as sql_util
+ return sql_util.ClauseAdapter(alias).traverse(self)
def correspond_on_equivalents(self, column, equivalents):
"""Return corresponding_column for the given column, or if None
diff --git a/lib/sqlalchemy/sql/util.py b/lib/sqlalchemy/sql/util.py
index dda5d2d28..b81906396 100644
--- a/lib/sqlalchemy/sql/util.py
+++ b/lib/sqlalchemy/sql/util.py
@@ -288,7 +288,6 @@ class Annotated(object):
# so that the resulting objects are pickleable.
annotated_classes = {}
-from sqlalchemy.sql import expression
for cls in expression.__dict__.values() + [schema.Column, schema.Table]:
if isinstance(cls, type) and issubclass(cls, expression.ClauseElement):
exec "class Annotated%s(Annotated, cls):\n" \
diff --git a/lib/sqlalchemy/types.py b/lib/sqlalchemy/types.py
index 1fdf643c7..4d86dc362 100644
--- a/lib/sqlalchemy/types.py
+++ b/lib/sqlalchemy/types.py
@@ -1285,9 +1285,8 @@ class SchemaType(object):
def create(self, bind=None, checkfirst=False):
"""Issue CREATE ddl for this type, if applicable."""
- from sqlalchemy.schema import _bind_or_error
if bind is None:
- bind = _bind_or_error(self)
+ bind = schema._bind_or_error(self)
t = self.dialect_impl(bind.dialect)
if t is not self and isinstance(t, SchemaType):
t.create(bind=bind, checkfirst=checkfirst)
@@ -1295,9 +1294,8 @@ class SchemaType(object):
def drop(self, bind=None, checkfirst=False):
"""Issue DROP ddl for this type, if applicable."""
- from sqlalchemy.schema import _bind_or_error
if bind is None:
- bind = _bind_or_error(self)
+ bind = schema._bind_or_error(self)
t = self.dialect_impl(bind.dialect)
if t is not self and isinstance(t, SchemaType):
t.drop(bind=bind, checkfirst=checkfirst)