summaryrefslogtreecommitdiff
path: root/examples/performance/single_inserts.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/performance/single_inserts.py')
-rw-r--r--examples/performance/single_inserts.py66
1 files changed, 38 insertions, 28 deletions
diff --git a/examples/performance/single_inserts.py b/examples/performance/single_inserts.py
index cfce90300..79e34dfe6 100644
--- a/examples/performance/single_inserts.py
+++ b/examples/performance/single_inserts.py
@@ -28,7 +28,7 @@ Profiler.init("single_inserts", num=10000)
def setup_database(dburl, echo, num):
global engine
engine = create_engine(dburl, echo=echo)
- if engine.dialect.name == 'sqlite':
+ if engine.dialect.name == "sqlite":
engine.pool = pool.StaticPool(creator=engine.pool._creator)
Base.metadata.drop_all(engine)
Base.metadata.create_all(engine)
@@ -42,8 +42,9 @@ def test_orm_commit(n):
session = Session(bind=engine)
session.add(
Customer(
- name='customer name %d' % i,
- description='customer description %d' % i)
+ name="customer name %d" % i,
+ description="customer description %d" % i,
+ )
)
session.commit()
@@ -54,11 +55,14 @@ def test_bulk_save(n):
for i in range(n):
session = Session(bind=engine)
- session.bulk_save_objects([
- Customer(
- name='customer name %d' % i,
- description='customer description %d' % i
- )])
+ session.bulk_save_objects(
+ [
+ Customer(
+ name="customer name %d" % i,
+ description="customer description %d" % i,
+ )
+ ]
+ )
session.commit()
@@ -68,11 +72,15 @@ def test_bulk_insert_dictionaries(n):
for i in range(n):
session = Session(bind=engine)
- session.bulk_insert_mappings(Customer, [
- dict(
- name='customer name %d' % i,
- description='customer description %d' % i
- )])
+ session.bulk_insert_mappings(
+ Customer,
+ [
+ dict(
+ name="customer name %d" % i,
+ description="customer description %d" % i,
+ )
+ ],
+ )
session.commit()
@@ -85,9 +93,9 @@ def test_core(n):
conn.execute(
Customer.__table__.insert(),
dict(
- name='customer name %d' % i,
- description='customer description %d' % i
- )
+ name="customer name %d" % i,
+ description="customer description %d" % i,
+ ),
)
@@ -102,9 +110,9 @@ def test_core_query_caching(n):
conn.execution_options(compiled_cache=cache).execute(
ins,
dict(
- name='customer name %d' % i,
- description='customer description %d' % i
- )
+ name="customer name %d" % i,
+ description="customer description %d" % i,
+ ),
)
@@ -123,20 +131,22 @@ def test_dbapi_raw_w_pool(n):
def _test_dbapi_raw(n, connect):
- compiled = Customer.__table__.insert().values(
- name=bindparam('name'),
- description=bindparam('description')).\
- compile(dialect=engine.dialect)
+ compiled = (
+ Customer.__table__.insert()
+ .values(name=bindparam("name"), description=bindparam("description"))
+ .compile(dialect=engine.dialect)
+ )
if compiled.positional:
args = (
- ('customer name %d' % i, 'customer description %d' % i)
- for i in range(n))
+ ("customer name %d" % i, "customer description %d" % i)
+ for i in range(n)
+ )
else:
args = (
dict(
- name='customer name %d' % i,
- description='customer description %d' % i
+ name="customer name %d" % i,
+ description="customer description %d" % i,
)
for i in range(n)
)
@@ -162,5 +172,5 @@ def _test_dbapi_raw(n, connect):
conn.close()
-if __name__ == '__main__':
+if __name__ == "__main__":
Profiler.main()