-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdb_init.py
47 lines (42 loc) · 951 Bytes
/
db_init.py
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
40
41
42
43
44
45
46
47
import sqlite3
# Define the schema for the task lists table
task_lists_table = """
CREATE TABLE task_lists (
kind TEXT,
id TEXT PRIMARY KEY,
etag TEXT,
title TEXT NOT NULL,
updated DATETIME,
selfLink TEXT
);
"""
# Define the schema for the tasks table
tasks_table = """
CREATE TABLE tasks (
id TEXT PRIMARY KEY,
etag TEXT,
title TEXT NOT NULL,
updated DATETIME,
selfLink TEXT,
parent TEXT,
position INTEGER,
notes TEXT,
status TEXT,
due DATETIME,
completed DATETIME,
deleted INTEGER,
hidden INTEGER,
webViewLink TEXT
task_list_id TEXT REFERENCES task_lists(id),
FOREIGN KEY (task_list_id) REFERENCES task_lists(id)
);
"""
# Create a connection to the database
conn = sqlite3.connect("tasks.db")
# Create the tables
with conn:
cursor = conn.cursor()
cursor.execute(task_lists_table)
cursor.execute(tasks_table)
# Close the connection
conn.close()