diff options
| author | leonoverweel <l.overweel@gmail.com> | 2017-02-27 15:58:57 +0100 |
|---|---|---|
| committer | leonoverweel <l.overweel@gmail.com> | 2017-02-27 15:58:57 +0100 |
| commit | c4d43ebc5f6db3015c41ae6381e2f30198f5e41d (patch) | |
| tree | d2c308d5e357c431b3c29303b322a546ea8e8fcf /database/rebuild-database.py | |
| parent | 6dd522632d5c47d9af3aae943df1a5d238e698cc (diff) | |
| parent | efb1a88fbf7c7993af0aff4b6eeac22232f72bcc (diff) | |
Merge branch 'master' into workload-core-occupation
Diffstat (limited to 'database/rebuild-database.py')
| -rw-r--r-- | database/rebuild-database.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/database/rebuild-database.py b/database/rebuild-database.py new file mode 100644 index 00000000..6e10b646 --- /dev/null +++ b/database/rebuild-database.py @@ -0,0 +1,31 @@ +import os +import sqlite3 +import sys + +sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0) + +try: + BASE_DIR = directory_name=sys.argv[1] +except: + BASE_DIR = os.path.dirname(os.path.abspath(__file__)) +db_location = os.path.join(BASE_DIR, 'opendc.db') + +print "Removing old database..." +os.remove(db_location) + +print "Connecting to new database..." +conn = sqlite3.connect(db_location) +c = conn.cursor() + +print "Importing schema..." +with open('schema.sql') as schema: + c.executescript(schema.read()) + +print "Importing test data..." +with open('test.sql') as test: + c.executescript(test.read()) + +conn.commit() +conn.close() + +print "Done." |
