MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_dbapi_raw

Function test_dbapi_raw

examples/performance/bulk_inserts.py:136–163  ·  view source on GitHub ↗

The DBAPI's API inserting rows in bulk.

(n)

Source from the content-addressed store, hash-verified

134
135@Profiler.profile
136def test_dbapi_raw(n):
137 """The DBAPI's API inserting rows in bulk."""
138
139 conn = engine.pool._creator()
140 cursor = conn.cursor()
141 compiled = (
142 Customer.__table__.insert()
143 .values(name=bindparam("name"), description=bindparam("description"))
144 .compile(dialect=engine.dialect)
145 )
146
147 if compiled.positional:
148 args = (
149 ("customer name %d" % i, "customer description %d" % i)
150 for i in range(n)
151 )
152 else:
153 args = (
154 dict(
155 name="customer name %d" % i,
156 description="customer description %d" % i,
157 )
158 for i in range(n)
159 )
160
161 cursor.executemany(str(compiled), list(args))
162 conn.commit()
163 conn.close()
164
165
166if __name__ == "__main__":

Callers

nothing calls this directly

Calls 9

bindparamFunction · 0.90
_creatorMethod · 0.45
cursorMethod · 0.45
compileMethod · 0.45
valuesMethod · 0.45
insertMethod · 0.45
executemanyMethod · 0.45
commitMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected