summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-09-04 20:55:38 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2014-09-04 20:55:38 -0400
commitd2c05c36a5c5f5b4838e924b4de2280f73916c99 (patch)
tree0c4b3ed4dbda7dfcdbf953e465e96a37065f0b21 /examples
parenteb81531275c07a0ab8c74eadc7881cfcff27ba21 (diff)
downloadsqlalchemy-d2c05c36a5c5f5b4838e924b4de2280f73916c99.tar.gz
- add a test that shows query caching.
Diffstat (limited to 'examples')
-rw-r--r--examples/performance/single_inserts.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/examples/performance/single_inserts.py b/examples/performance/single_inserts.py
index 671bbbe9c..4178ccea8 100644
--- a/examples/performance/single_inserts.py
+++ b/examples/performance/single_inserts.py
@@ -88,6 +88,23 @@ def test_core(n):
@Profiler.profile
+def test_core_query_caching(n):
+ """Individual INSERT/COMMIT pairs using Core with query caching"""
+
+ cache = {}
+ ins = Customer.__table__.insert()
+ for i in range(n):
+ with engine.begin() as conn:
+ conn.execution_options(compiled_cache=cache).execute(
+ ins,
+ dict(
+ name='customer name %d' % i,
+ description='customer description %d' % i
+ )
+ )
+
+
+@Profiler.profile
def test_dbapi_raw_w_connect(n):
"""Individual INSERT/COMMIT pairs using a pure DBAPI connection,
connect each time."""
@@ -130,6 +147,7 @@ def _test_dbapi_raw(n, connect):
conn = engine.pool._creator()
cursor = conn.cursor()
cursor.execute(sql, arg)
+ lastrowid = cursor.lastrowid
conn.commit()
conn.close()
else:
@@ -137,6 +155,7 @@ def _test_dbapi_raw(n, connect):
conn = engine.raw_connection()
cursor = conn.cursor()
cursor.execute(sql, arg)
+ lastrowid = cursor.lastrowid
conn.commit()
conn.close()