MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / setup_database

Function setup_database

examples/performance/bulk_updates.py:31–49  ·  view source on GitHub ↗
(dburl, echo, num)

Source from the content-addressed store, hash-verified

29
30@Profiler.setup
31def setup_database(dburl, echo, num):
32 global engine
33 engine = create_engine(dburl, echo=echo)
34 Base.metadata.drop_all(engine)
35 Base.metadata.create_all(engine)
36
37 s = Session(engine)
38 for chunk in range(0, num, 10000):
39 s.bulk_insert_mappings(
40 Customer,
41 [
42 {
43 "name": "customer name %d" % i,
44 "description": "customer description %d" % i,
45 }
46 for i in range(chunk, chunk + 10000)
47 ],
48 )
49 s.commit()
50
51
52@Profiler.profile

Callers

nothing calls this directly

Calls 6

bulk_insert_mappingsMethod · 0.95
commitMethod · 0.95
create_engineFunction · 0.90
SessionClass · 0.90
drop_allMethod · 0.80
create_allMethod · 0.80

Tested by

no test coverage detected