summaryrefslogtreecommitdiff
path: root/examples/performance/single_inserts.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2019-01-06 01:14:26 -0500
committermike bayer <mike_mp@zzzcomputing.com>2019-01-06 17:34:50 +0000
commit1e1a38e7801f410f244e4bbb44ec795ae152e04e (patch)
tree28e725c5c8188bd0cfd133d1e268dbca9b524978 /examples/performance/single_inserts.py
parent404e69426b05a82d905cbb3ad33adafccddb00dd (diff)
downloadsqlalchemy-1e1a38e7801f410f244e4bbb44ec795ae152e04e.tar.gz
Run black -l 79 against all source files
This is a straight reformat run using black as is, with no edits applied at all. The black run will format code consistently, however in some cases that are prevalent in SQLAlchemy code it produces too-long lines. The too-long lines will be resolved in the following commit that will resolve all remaining flake8 issues including shadowed builtins, long lines, import order, unused imports, duplicate imports, and docstring issues. Change-Id: I7eda77fed3d8e73df84b3651fd6cfcfe858d4dc9
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()