aboutsummaryrefslogtreecommitdiff
path: root/src/db/init.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/db/init.py')
-rw-r--r--src/db/init.py18
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