aboutsummaryrefslogtreecommitdiff
path: root/src/db/init.py
blob: cb8a4a85574b8aa97c33e0c615cb50706bb705d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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,"
            "   description TEXT,"
            "   duration INTEGER,"
            "   tag TEXT"
            " )")
        database.commit()
    return database