blob: 8292dfc92ee42eb0660f17756531bc00ce9aa748 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
import sqlite3
import os.path
import time
def init(path):
is_db_new = not os.path.isfile(path)
database = sqlite3.connect(path)
if is_db_new:
cursor = database.cursor()
cursor.execute(
" CREATE TABLE IF NOT EXISTS tasks("
" id INTEGER PRIMARY KEY,"
" created_at INTEGER NOT NULL,"
" updated_at INTEGER NOT NULL,"
" name TEXT NOT NULL,"
" duration INTEGER,"
" tag TEXT,"
" difficulty INT,"
" 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
|