-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
44 lines (38 loc) · 1.49 KB
/
main.py
File metadata and controls
44 lines (38 loc) · 1.49 KB
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
39
40
41
42
43
44
from database import DatabaseManager
from weather_fetcher import WeatherFetcher
def main():
db = DatabaseManager()
fetcher = WeatherFetcher()
while True:
print("\n1. Időjárás lekérése és mentése")
print("2. Mentett adatok lekérdezése város alapján")
print("3. Adatok törlése város alapján")
print("4. Kilépés")
choice = input("Válassz egy opciót: ")
if choice == "1":
city = input("Add meg a város nevét: ")
weather_data = fetcher.fetch_weather(city)
if weather_data:
db.add_weather(weather_data)
print(f"{city.capitalize()} időjárása mentve az adatbázisba.")
elif choice == "2":
city = input("Add meg a város nevét: ")
results = db.get_weather_by_city(city)
if results:
for record in results:
print(
f"{record.timestamp} | {record.city} | {record.temperature}°C | {record.description}"
)
else:
print("Nincs találat.")
elif choice == "3":
city = input("Melyik város adatait töröljük?: ")
db.delete_weather_by_city(city)
print("Törlés kész.")
elif choice == "4":
print("Kilépve!")
break
else:
print("Érvénytelen választás.")
if __name__ == "__main__":
main()