import re
from .. import exc, util
from . import Dialect
+from ..dialects import registry
class URL(object):
name = self.drivername
else:
name = self.drivername.replace('+', '.')
- from sqlalchemy.dialects import registry
cls = registry.load(name)
# check for legacy dialects that
# would return a module with 'dialect' as the
from ..sql import util as sql_util
from .util import _none_set, state_str
from .. import exc as sa_exc
+
+querylib = util.importlater("sqlalchemy.orm", "query")
sessionlib = util.importlater("sqlalchemy.orm", "session")
_new_runid = util.counter()
def merge_result(query, iterator, load=True):
"""Merge a result into this :class:`.Query` object's Session."""
- from . import query as querylib
-
session = query.session
if load:
# flush current contents if we expect to load data
from .interfaces import MANYTOMANY, MANYTOONE, ONETOMANY,\
PropComparator, StrategizedProperty
+dynamic = util.importlater("sqlalchemy.orm", "dynamic")
mapperlib = util.importlater("sqlalchemy.orm", "mapperlib")
NoneType = type(None)
if strategy_class:
self.strategy_class = strategy_class
elif self.lazy == 'dynamic':
- from sqlalchemy.orm import dynamic
self.strategy_class = dynamic.DynaLoader
else:
self.strategy_class = strategies.factory(self.lazy)
util as sql_util,
expression, visitors
)
+properties = util.importlater("sqlalchemy.orm", "properties")
__all__ = ['Query', 'QueryContext', 'aliased']
"""
if property is None:
- from sqlalchemy.orm import properties
mapper = object_mapper(instance)
for prop in mapper.iterate_properties:
# determine if our "lazywhere" clause is the same as the mapper's
# get() clause. then we can just use mapper.get()
- #from sqlalchemy.orm import query
self.use_get = not self.uselist and \
self.mapper._get_clause[0].compare(
self._lazywhere,
from . import exc, util, dialects, event, events, inspection
from .sql import expression, visitors
import collections
+import sqlalchemy
ddl = util.importlater("sqlalchemy.engine", "ddl")
sqlutil = util.importlater("sqlalchemy.sql", "util")
"""Bind this MetaData to an Engine, Connection, string or URL."""
if isinstance(bind, util.string_types + (url.URL, )):
- from sqlalchemy import create_engine
- self._bind = create_engine(bind)
+ self._bind = sqlalchemy.create_engine(bind)
else:
self._bind = bind
bind = property(bind, _bind_to)
try:
self.context._engine = self.__engines[bind]
except KeyError:
- from sqlalchemy import create_engine
- e = create_engine(bind)
+ e = sqlalchemy.create_engine(bind)
self.__engines[bind] = e
self.context._engine = e
else: