Skip to content

Commit 4eca7a4

Browse files
author
Ilia Shcheglov
committed
Added read from last day table
1 parent 4b78be1 commit 4eca7a4

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

create_db.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
temperature REAL NOT NULL,
1616
humidity REAL NOT NULL
1717
);
18-
18+
''')
19+
cursor.execute('''
1920
CREATE TABLE IF NOT EXISTS last_day_sensor_data (
2021
id INTEGER PRIMARY KEY AUTOINCREMENT,
2122
date TEXT NOT NULL,
2223
co2 INTEGER NOT NULL,
2324
temperature REAL NOT NULL,
2425
humidity REAL NOT NULL
2526
);
26-
2727
''')
2828
conn.commit()
2929
conn.close()

web_service/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def fetch_last_day():
6464
try:
6565
# Connect to the SQLite database
6666
conn = sqlite3.connect(DB_NAME)
67-
query = "SELECT date, co2, temperature, humidity FROM last_day_sensor_data WHERE date > datetime('now', '-24 hours');"
67+
query = "SELECT date, co2, temperature, humidity FROM last_day_sensor_data;"
6868
df = pd.read_sql_query(query, conn)
6969

7070
# Convert 'date' column to datetime

0 commit comments

Comments
 (0)