summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJackson Taylor <jtaylor@classicalconversations.com>2021-11-01 16:07:41 -0400
committerJackson Taylor <jtaylor@classicalconversations.com>2021-11-01 16:07:41 -0400
commitce54f3c98cf618e6dfc8d933c944798562483901 (patch)
treea1b6cd7e563405b77fc0d48ef83d3d93514ebee6
parent4c7dc8b854ae849b80c786a77307435b3b0af401 (diff)
Add -s flag
Create the database tables conditionally
-rwxr-xr-xjacsr15
1 files changed, 12 insertions, 3 deletions
diff --git a/jacsr b/jacsr
index c64f2ba..9b960b9 100755
--- a/jacsr
+++ b/jacsr
@@ -3,6 +3,7 @@ import csv
import sqlite3
import sys
+# TODO: Parameterize with getopt. These should be fine defaults.
RESULT_FILE = './cstimer.csv'
DATABASE_FILE = 'solves.db'
@@ -48,17 +49,25 @@ def usage():
print("""
jacsr - Jackson's Awesome Cube Statistics Recorder
-h - show this help message
+-s - Setup database with the tables
""")
if __name__ == "__main__":
+ setup_db = False
+
+ # TODO: Use getopt instead
if len(sys.argv) > 1:
- usage()
- sys.exit()
+ if sys.argv[1] == '-s':
+ setup_db = True
+ else:
+ usage()
+ sys.exit()
connection = sqlite3.connect(DATABASE_FILE)
- create_solve_table(connection)
+ if setup_db:
+ create_solve_table(connection)
insert_times_into_db(connection, RESULT_FILE)