diff options
author | Joris | 2020-05-08 14:12:47 +0200 |
---|---|---|
committer | Joris | 2020-05-08 14:14:16 +0200 |
commit | df828c4b141f84f731afffbe17c80618cacf9480 (patch) | |
tree | aeae4a185c3f23da0331b32139c072ebe50b50dd /src/db/init.py | |
parent | 2abfaddc6a3a5233018ad285421eaf531a01a283 (diff) |
Bootstrap todo-next
Diffstat (limited to 'src/db/init.py')
-rw-r--r-- | src/db/init.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/db/init.py b/src/db/init.py new file mode 100644 index 0000000..9517714 --- /dev/null +++ b/src/db/init.py @@ -0,0 +1,18 @@ +import sqlite3 +import os.path +import time + +def init(path): + is_db_new = not os.path.isfile(path) + database = sqlite3.connect('database') + if is_db_new: + database.cursor().execute( + " CREATE TABLE IF NOT EXISTS tasks(" + " id INTEGER PRIMARY KEY," + " created_at INTEGER NOT NULL," + " modified_at INTEGER NOT NULL," + " name TEXT NOT NULL," + " tag TEXT" + " )") + database.commit() + return database |