aboutsummaryrefslogtreecommitdiff
path: root/src/db/init.py
diff options
context:
space:
mode:
authorJoris2020-05-10 20:24:24 +0200
committerJoris2020-05-10 20:24:24 +0200
commit8a6e10d401eea8db0947f8c4b309b8a6256f9748 (patch)
tree6e2dc6956ce7825f0f1b6c3ed6f0b4171fe9c274 /src/db/init.py
parent3e1415c738facb8b0274adb50ae65f218fd59c9b (diff)
downloadtodo-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.py21
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