From df828c4b141f84f731afffbe17c80618cacf9480 Mon Sep 17 00:00:00 2001 From: Joris Date: Fri, 8 May 2020 14:12:47 +0200 Subject: Bootstrap todo-next --- src/db/init.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/db/init.py (limited to 'src/db/init.py') 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 -- cgit v1.2.3