diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-08-10 18:12:30 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-08-10 18:12:30 +0000 |
commit | dedcf82fa31884fcefefb75515d195e1bc3b9148 (patch) | |
tree | 7ad26b8b0ce53f2d8a689ace587831cb9c71c32a | |
parent | 219bcf8cb17bdfeb526c72b29ec8ece5127f6c98 (diff) | |
download | sqlalchemy-dedcf82fa31884fcefefb75515d195e1bc3b9148.tar.gz |
--dropfirst option added, defaults to False. pre-drops tables when set to True, reportedly mis-behaves on Oracle, MS-SQL.
-rw-r--r-- | test/testlib/config.py | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/test/testlib/config.py b/test/testlib/config.py index 77cacc820..719dcf6c0 100644 --- a/test/testlib/config.py +++ b/test/testlib/config.py @@ -103,6 +103,8 @@ opt('--dbs', action='callback', callback=_list_dbs, help="List available prefab dbs") opt("--dburi", action="store", dest="dburi", help="Database uri (overrides --db)") +opt("--dropfirst", action="store_true", dest="dropfirst", + help="Drop all tables in the target database first (use with caution on Oracle, MS-SQL)") opt("--mockpool", action="store_true", dest="mockpool", help="Use mock pool (asserts only one connection used)") opt("--enginestrategy", action="callback", type="string", @@ -207,20 +209,21 @@ def _prep_testing_database(options, file_config): try: # also create alt schemas etc. here? - e = engines.utf8_engine() - existing = e.table_names() - if existing: - if not options.quiet: - print "Dropping existing tables in database: " + db_url - try: - print "Tables: %s" % ', '.join(existing) - except: - pass - print "Abort within 5 seconds..." - time.sleep(5) - md = schema.MetaData(e, reflect=True) - md.drop_all() - e.dispose() + if options.dropfirst: + e = engines.utf8_engine() + existing = e.table_names() + if existing: + if not options.quiet: + print "Dropping existing tables in database: " + db_url + try: + print "Tables: %s" % ', '.join(existing) + except: + pass + print "Abort within 5 seconds..." + time.sleep(5) + md = schema.MetaData(e, reflect=True) + md.drop_all() + e.dispose() except (KeyboardInterrupt, SystemExit): raise except Exception, e: |