create_engine(... isolation_level="..."); available on
postgresql and sqlite. [ticket:443]
+- schema
+ - metadata.connect() and threadlocalmetadata.connect() have been removed.
+ - new CreateTable,DropTable,CreateSequence,DropSequence, etc.
+
- dialect refactor
- the "owner" keyword argument is removed from Table. Use "schema" to
represent any namespaces to be prepended to the table name.
"""Construct a new TLEngine."""
super(TLEngine, self).__init__(*args, **kwargs)
- self.context = util.ThreadLocal()
+ self.context = util.threading.local()
proxy = kwargs.get('proxy')
if proxy:
from sqlalchemy import exc, log
from sqlalchemy import queue as sqla_queue
-from sqlalchemy.util import thread, threading, pickle, as_interface
+from sqlalchemy.util import threading, pickle, as_interface
proxies = {}
return self._bind is not None
- @util.deprecated('Deprecated. Use ``metadata.bind = <engine>`` or '
- '``metadata.bind = <url>``.')
- def connect(self, bind, **kwargs):
- """Bind this MetaData to an Engine.
-
- bind
- A string, ``URL``, ``Engine`` or ``Connection`` instance. If a
- string or ``URL``, will be passed to ``create_engine()`` along with
- ``\**kwargs`` to produce the engine which to connect to. Otherwise
- connects directly to the given ``Engine``.
-
- """
- global URL
- if URL is None:
- from sqlalchemy.engine.url import URL
- if isinstance(bind, (basestring, URL)):
- from sqlalchemy import create_engine
- self._bind = create_engine(bind, **kwargs)
- else:
- self._bind = bind
-
def bind(self):
"""An Engine or Connection to which this MetaData is bound.
def __init__(self):
"""Construct a ThreadLocalMetaData."""
- self.context = util.ThreadLocal()
+ self.context = util.threading.local()
self.__engines = {}
super(ThreadLocalMetaData, self).__init__()
- @util.deprecated('Deprecated. Use ``metadata.bind = <engine>`` or '
- '``metadata.bind = <url>``.')
- def connect(self, bind, **kwargs):
- """Bind to an Engine in the caller's thread.
-
- bind
- A string, ``URL``, ``Engine`` or ``Connection`` instance. If a
- string or ``URL``, will be passed to ``create_engine()`` along with
- ``\**kwargs`` to produce the engine which to connect to. Otherwise
- connects directly to the given ``Engine``.
- """
-
- global URL
- if URL is None:
- from sqlalchemy.engine.url import URL
-
- if isinstance(bind, (basestring, URL)):
- try:
- engine = self.__engines[bind]
- except KeyError:
- from sqlalchemy import create_engine
- engine = create_engine(bind, **kwargs)
- bind = engine
- self._bind_to(bind)
-
def bind(self):
"""The bound Engine or Connection for this thread.
from sqlalchemy import exc
try:
- import thread as thread, threading as threading
- from threading import local as ThreadLocal
+ import threading as threading
except ImportError:
- import dummy_thread as thread
import dummy_threading as threading
- from dummy_threading import local as ThreadLocal
py3k = getattr(sys, 'py3kwarning', False) or sys.version_info >= (3, 0)
rt = Table('t_defaults', m2, autoload=True)
expected = [c[1] for c in specs]
for i, reflected in enumerate(rt.c):
- self.assertEquals(reflected.server_default.arg.text, expected[i])
+ self.assertEquals(reflected.server_default.arg, expected[i])
finally:
m.drop_all()
rt = Table('r_defaults', m, autoload=True)
for i, reflected in enumerate(rt.c):
- self.assertEquals(reflected.server_default.arg.text, expected[i])
+ self.assertEquals(reflected.server_default.arg, expected[i])
finally:
db.execute("DROP TABLE r_defaults")
table = Table('test_table', metadata,
Column('foo', Integer))
- metadata.connect(bind)
+ metadata.bind = bind
assert metadata.bind is table.bind is bind
metadata.create_all()