-
Notifications
You must be signed in to change notification settings - Fork 0
/
Data.py
38 lines (27 loc) · 813 Bytes
/
Data.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
# Author: Oluwakemi Toluwalase Obadeyi
# Date: 03/10/2023
import sqlite3
from sqlite3 import Error
def create_connection(db_file):
"""create a database connection to a SQLite database"""
conn = None
try:
conn = sqlite3.connect(db_file)
except Error as e:
print(e)
return conn
def get_drivers(conn):
sql = """ SELECT * FROM Drivers"""
cursor = conn.cursor()
cursor.execute(sql)
return cursor.fetchall()
def get_bookings(conn):
sql = """ SELECT * FROM Bookings"""
cursor = conn.cursor()
cursor.execute(sql)
return cursor.fetchall()
def cancel_previous_booking(conn, id):
sql = "DELETE FROM Bookings WHERE bookingid=?"
cursor = conn.cursor()
cursor.execute(sql, (id,))
conn.commit()