diff options
author | Joris | 2020-05-10 20:24:24 +0200 |
---|---|---|
committer | Joris | 2020-05-10 20:24:24 +0200 |
commit | 8a6e10d401eea8db0947f8c4b309b8a6256f9748 (patch) | |
tree | 6e2dc6956ce7825f0f1b6c3ed6f0b4171fe9c274 /src/db/init.py | |
parent | 3e1415c738facb8b0274adb50ae65f218fd59c9b (diff) | |
download | todo-8a6e10d401eea8db0947f8c4b309b8a6256f9748.tar.gz todo-8a6e10d401eea8db0947f8c4b309b8a6256f9748.tar.bz2 todo-8a6e10d401eea8db0947f8c4b309b8a6256f9748.zip |
Add tags panel
Diffstat (limited to 'src/db/init.py')
-rw-r--r-- | src/db/init.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/db/init.py b/src/db/init.py index 8fb7098..8292dfc 100644 --- a/src/db/init.py +++ b/src/db/init.py @@ -3,14 +3,20 @@ import os.path import time def init(path): + is_db_new = not os.path.isfile(path) + database = sqlite3.connect(path) + if is_db_new: - database.cursor().execute( + + cursor = database.cursor() + + cursor.execute( " CREATE TABLE IF NOT EXISTS tasks(" " id INTEGER PRIMARY KEY," " created_at INTEGER NOT NULL," - " modified_at INTEGER NOT NULL," + " updated_at INTEGER NOT NULL," " name TEXT NOT NULL," " duration INTEGER," " tag TEXT," @@ -18,5 +24,16 @@ def init(path): " priority INT," " description TEXT" " )") + + cursor.execute( + " CREATE TABLE IF NOT EXISTS tags(" + " id INTEGER PRIMARY KEY," + " created_at INTEGER NOT NULL," + " updated_at INTEGER NOT NULL," + " name TEXT NOT NULL," + " color TEXT NOT NULL" + " )") + database.commit() + return database |