Fixed up the code. Now just need to fix the add_task command
This commit is contained in:
@@ -3,33 +3,34 @@ from datetime import datetime
|
||||
|
||||
DATABASE = "dolly.db"
|
||||
|
||||
async def setup_db():
|
||||
async def init_db():
|
||||
async with aiosqlite.connect(DATABASE) as db:
|
||||
await db.execute('''CREATE TABLE IF NOT EXISTS projects (
|
||||
id INTEGER PRIMARY KEY,
|
||||
name TEXT UNIQUE,
|
||||
description TEXT)'''
|
||||
await db.execute(
|
||||
'''CREATE TABLE IF NOT EXISTS projects(
|
||||
id INTEGER PRIMARY KEY,
|
||||
name TEXT UNIQUE,
|
||||
description TEXT)'''
|
||||
)
|
||||
await db.execute('''CREATE TABLE IF NOT EXISTS tasks (
|
||||
id INTEGER PRIMARY KEY,
|
||||
project_id INTEGER,
|
||||
description TEXT,
|
||||
assignee text,
|
||||
deadline DATE,
|
||||
status TEXT,
|
||||
priority TEXT,
|
||||
FOREIGN KEY(project_id) REFERENCES projects(id))'''
|
||||
await db.execute(
|
||||
'''CREATE TABLE IF NOT EXISTS tasks(
|
||||
id INTEGER PRIMARY KEY,
|
||||
project_id INTEGER,
|
||||
description TEXT,
|
||||
assignee TEXT,
|
||||
deadline TEXT,
|
||||
status TEXT,
|
||||
priority TEXT,
|
||||
FOREIGN KEY(project_id) REFERENCES projects(id))'''
|
||||
)
|
||||
await db.commit()
|
||||
|
||||
async def add_project(name, description):
|
||||
async with aiosqlite.connect(DATABASE) as db:
|
||||
await db.execute("INSERT INTO projects (name, description) VALUES (?, ?)", (name, description))
|
||||
await db.execute("INSERT INTO projects(name, description) VALUES(?, ?)", (name, description))
|
||||
await db.commit()
|
||||
|
||||
async def add_task(project_id, description, assignee, deadline, status, priority):
|
||||
deadline_date = datetime.strptime(deadline, '%Y-%m-%d').date()
|
||||
async with aiosqlite.connect(DATABASE) as db:
|
||||
await db.execute("INSERT INTO tasks (project_id, description, assignee, deadline, status, priority) VALUES (?, ?, ?, ?, ?, ?)",
|
||||
(project_id, description, assignee, deadline_date, status, priority))
|
||||
deadline_date = datetime.strptime(deadline, "%Y-%m-%d").date()
|
||||
await db.execute("INSERT INTO tasks(project_id, description, assignee, deadline, status, priority) VALUES(?, ?, ?, ?, ?, ?)", (project_id, description, assignee, deadline_date, status, priority))
|
||||
await db.commit()
|
Reference in New Issue
Block a user