-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdata_store.py
More file actions
98 lines (75 loc) · 2.68 KB
/
data_store.py
File metadata and controls
98 lines (75 loc) · 2.68 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from board import Board
from board_list import BoardList
from user import User
from item import Item
from database_orm import BoardData
from sqlalchemy.orm import sessionmaker
from database_orm import BoardData,ListItems,Taskcard
from sqlalchemy import create_engine
from database_orm import BoardData
class DataStore:
def connect(self):
engine=create_engine('sqlite:///trolly.sqlite3')
Session =sessionmaker(bind=engine)
return Session()
def add_board(self, model) -> None:
db = self.connect()
if isinstance(model, str):
board = BoardData(board_name = model)
else:
board = BoardData(board_name=model.value)
db.add(board)
db.commit()
db.close()
def get_board(self, id) -> "Board":
db=self.connect()
obj=db.query(BoardData).get(id)
db.close()
return obj
def get_boards(self) -> list["Board"]:
db = self.connect()
boards = db.query(BoardData).all()
# for boards in board:
# print(boards.board_name,boards.board_id)
# obj=db.query(BoardData).select_from(BoardData).get(all)
# obj=db.SELECT(Board).where(BoardData.c.board_id==1)
db.close()
return boards
def update_board(self, model, update):
raise NotImplementedError
def remove_board(self, board) -> None:
db=self.connect()
print(board)
db.query(BoardData).filter(BoardData.board_id==board.board_id).delete()
db.commit()
db.close()
def add_user(self, model) -> None:
raise NotImplementedError
def get_users(self) -> list["User"]:
raise NotImplementedError
def get_user(self, id) -> "User":
raise NotImplementedError
def remove_user(self, id) -> None:
raise NotImplementedError
def add_list(self, board, model) -> None:
raise NotImplementedError
def get_lists(self) -> list["BoardList"]:
raise NotImplementedError
def get_list(self, id) -> "BoardList":
raise []
def get_lists_by_board(self, board) -> list["BoardList"]:
return []
def remove_list(self, board, id) -> None:
raise NotImplementedError
def add_item(self, board_list, model) -> None:
raise NotImplementedError
def get_items(self, board_list) -> list["Item"]:
raise NotImplementedError
def get_item(self, id) -> "Item":
raise NotImplementedError
def get_items_by_board(self, board) -> list["Item"]:
raise NotImplementedError
def remove_item(self, board_list, id) -> None:
raise NotImplementedError