-
Notifications
You must be signed in to change notification settings - Fork 0
/
view_database.py
32 lines (26 loc) · 984 Bytes
/
view_database.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
import sqlite3
DB_FILE = 'data/traffic_data.db'
def view_database():
with sqlite3.connect(DB_FILE) as conn:
cursor = conn.cursor()
# Check and display data from 'cars' table
print("Contents of the 'cars' table:")
cursor.execute("SELECT * FROM cars")
cars_data = cursor.fetchall()
if cars_data:
for row in cars_data:
print(row)
else:
print("No data found in the 'cars' table.")
print("\n" + "-" * 40 + "\n")
# Check and display data from 'weekly_limits' table
print("Contents of the 'weekly_limits' table:")
cursor.execute("SELECT * FROM weekly_limits")
weekly_limits_data = cursor.fetchall()
if weekly_limits_data:
for row in weekly_limits_data:
print(row)
else:
print("No data found in the 'weekly_limits' table.")
if __name__ == "__main__":
view_database()