pr.disable()
stats = pstats.Stats(pr).sort_stats('cumulative')
+ #stats.print_callers()
self.stats.append(TestResult(self, fn, stats=stats))
return result
s = Session(engine)
for chunk in range(0, num, 10000):
- s.bulk_insert_mappings(Customer, [
- {
- 'name': 'customer name %d' % i,
- 'description': 'customer description %d' % i
- } for i in range(chunk, chunk + 10000)
- ])
+ s.execute(
+ Customer.__table__.insert(),
+ params=[
+ {
+ 'name': 'customer name %d' % i,
+ 'description': 'customer description %d' % i
+ } for i in range(chunk, chunk + 10000)])
s.commit()
sess.add_all([
Customer(
id=i, name='c%d' % i, description="c%d" % i,
- q="q%d" % i,
- p="p%d" % i,
- x="x%d" % i,
- y="y%d" % i,
+ q=i * 10,
+ p=i * 20,
+ x=i * 30,
+ y=i * 40,
)
for i in ids
])
insp = inspection.inspect(entity, False)
return insp is not None and \
- hasattr(insp, "mapper") and \
+ not insp.is_clause_element and \
(
insp.is_mapper
or insp.is_aliased_class
"""If True, queries for a single Bundle will be returned as a single
entity, rather than an element within a keyed tuple."""
+ is_clause_element = False
+
+ is_mapper = False
+
+ is_aliased_class = False
+
def __init__(self, name, *exprs, **kw):
"""Construct a new :class:`.Bundle`.
seen = set()
translate = self._from_cloned
- def add(items):
- for item in items:
- if item is self:
- raise exc.InvalidRequestError(
- "select() construct refers to itself as a FROM")
- if translate and item in translate:
- item = translate[item]
- if not seen.intersection(item._cloned_set):
- froms.append(item)
- seen.update(item._cloned_set)
-
- add(_from_objects(*self._raw_columns))
- if self._whereclause is not None:
- add(_from_objects(self._whereclause))
- add(self._from_obj)
+ for item in itertools.chain(
+ _from_objects(*self._raw_columns),
+ _from_objects(self._whereclause)
+ if self._whereclause is not None else (),
+ self._from_obj
+ ):
+ if item is self:
+ raise exc.InvalidRequestError(
+ "select() construct refers to itself as a FROM")
+ if translate and item in translate:
+ item = translate[item]
+ if not seen.intersection(item._cloned_set):
+ froms.append(item)
+ seen.update(item._cloned_set)
return froms