-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtests.py
32 lines (21 loc) · 949 Bytes
/
tests.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 database
import json
from datetime import datetime
# Funções auxiliares
def date_from_timestamp(timestamp):
return timestamp.strftime('%Y-%m-%d')
def today():
return datetime.today().strftime('%Y-%m-%d')
db = database.Database('weather.db')
with db as connection:
# Insere locais no banco de dados
with open('data/locais.csv') as file:
db.load_locais(file)
with open('data/infos.json') as file:
infos = json.loads(file.read())
# Registra o acesso
#id_acesso = db.registra_acesso(1, today(), today())
#for obj in infos:
#print("Inserindo previsão {} {} {}".format(id_acesso, obj['date'].split()[1], obj['temperature']['temperature']))
#db.registra_previsao(id_acesso, obj['date'].split()[1], obj['temperature']['temperature'])
print(db.get_previsoes_filtradas(data_acesso='2022-08-28', data_previsao='2022-08-28', cidade="São Paulo", time="15:00:00"))