diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-08-14 17:34:17 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-08-14 17:34:17 +0000 |
| commit | 55e80ace66ea1fa1235397650bfcdbeaab25acf5 (patch) | |
| tree | 12f6001fc1dab9a11a4ae91972c6894bb0b20449 /test/perf | |
| parent | 5be79a6e32867002f6f17dedf584d66c5d10f696 (diff) | |
| download | sqlalchemy-55e80ace66ea1fa1235397650bfcdbeaab25acf5.tar.gz | |
a mass insert/ select benchmarking test, from
http://pyinsci.blogspot.com/2007/07/fastest-python-database-interface.html
Diffstat (limited to 'test/perf')
| -rw-r--r-- | test/perf/insertspeed.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test/perf/insertspeed.py b/test/perf/insertspeed.py new file mode 100644 index 000000000..ed363692d --- /dev/null +++ b/test/perf/insertspeed.py @@ -0,0 +1,31 @@ +import testbase +from sqlalchemy import * +from sqlalchemy.orm import * +from testlib import * + + +db = create_engine('sqlite://') +metadata = MetaData(db) +Person_table = Table('Person', metadata, + Column('name', String(40)), + Column('sex', Integer), + Column('age', Integer)) + +@profiling.profiled('test_many_inserts', always=True) +def test_many_inserts(n): + print "Inserting %s records into SQLite(memory) with SQLAlchemy"%n + i = Person_table.insert() + i.execute([{'name':'John Doe','sex':1,'age':35} for j in xrange(n)]) + s = Person_table.select() + r = s.execute() + print "Number of records selected: %s\n"%(len(r.fetchall())) + +def all(): + metadata.create_all() + try: + test_many_inserts(100000) + finally: + metadata.drop_all() + +if __name__ == '__main__': + all() |
