pywatts/pywatts/db.py

30 lines
640 B
Python
Raw Normal View History

from peewee import *
from playhouse import sqlite_ext
2018-05-17 14:19:05 +02:00
from playhouse.sqlite_ext import SqliteExtDatabase
db = SqliteExtDatabase('pywatts.db')
class WeatherStation(Model):
longitude = IntegerField()
latitude = IntegerField()
location = CharField()
elevation = IntegerField()
city = CharField()
state = CharField()
id = CharField(unique=True)
2018-05-17 14:19:05 +02:00
class Meta:
database = db
class Result(Model):
station = ForeignKeyField(WeatherStation)
dc_output = sqlite_ext.JSONField()
temperature = sqlite_ext.JSONField()
wind_speed = sqlite_ext.JSONField()
2018-05-17 14:19:05 +02:00
class Meta:
database = db