Skip to content

Instantly share code, notes, and snippets.

@gwax
Created December 1, 2015 17:36
Show Gist options
  • Save gwax/0f3936b468b597e8d93f to your computer and use it in GitHub Desktop.
Save gwax/0f3936b468b597e8d93f to your computer and use it in GitHub Desktop.
Comparing Schema dropping to DB dropping with testing.postgresql
import timeit
setup = """
import testing.postgresql
import sqlalchemy
postgres = testing.postgresql.Postgresql()
engine = sqlalchemy.create_engine(postgres.url())
conn = engine.connect()
conn.connection.connection.set_isolation_level(0)
"""
timed1 = """
conn.execute('CREATE SCHEMA test_schema')
conn.execute('DROP SCHEMA test_schema CASCADE')
"""
timed2 = """
conn.execute('CREATE DATABASE test_db')
conn.execute('DROP DATABASE test_db')
"""
timeit.timeit(setup=setup, stmt=timed1, number=100)
timeit.timeit(setup=setup, stmt=timed2, number=100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment