-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit_db.py
More file actions
30 lines (24 loc) · 720 Bytes
/
init_db.py
File metadata and controls
30 lines (24 loc) · 720 Bytes
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
import sqlite3
def initialize_database():
conn = sqlite3.connect("config.db")
cursor = conn.cursor()
# Create the settings table
cursor.execute("""
CREATE TABLE IF NOT EXISTS settings (
key TEXT PRIMARY KEY,
value TEXT NOT NULL
)
""")
# Insert default settings
default_settings = {
"weather_type": "METAR",
"station": "EHGR",
"interval": "5"
}
for key, value in default_settings.items():
cursor.execute("INSERT OR IGNORE INTO settings (key, value) VALUES (?, ?)", (key, value))
conn.commit()
conn.close()
if __name__ == "__main__":
initialize_database()
print("Database initialized with default settings.")