feat(backend): add the db connection
This commit is contained in:
15
backend/database/models/service.py
Normal file
15
backend/database/models/service.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from ..connection import DatabaseConnection
|
||||
|
||||
class Service:
|
||||
def __init__(self, service_type_id: int, service_date: str):
|
||||
self.service_type_id = service_type_id
|
||||
self.service_date = service_date
|
||||
|
||||
def save(self, db: DatabaseConnection):
|
||||
query = "INSERT INTO Services (ServiceTypeId, ServiceDate) VALUES (?, ?)"
|
||||
db.execute_query(query, (self.service_type_id, self.service_date))
|
||||
|
||||
@classmethod
|
||||
def get_all(cls, db: DatabaseConnection):
|
||||
query = "SELECT * FROM Services"
|
||||
return db.execute_query_with_return(query)
|
||||
Reference in New Issue
Block a user