import os
import sys
from peewee import *
from utils.DBModels.BaseModel import *
from utils.DBModels.DeviceModels import *
from utils.DBModels.DeviceParModels import *
class Client(object):
    def __init__(self):
        super(Client, self).__init__()

    @classmethod
    def initDB(self):
        dbPath = os.path.join('db', 'project.db')
        if os.path.isfile(dbPath):
            self.deviceDB = SqliteDatabase(dbPath)
            client_proxy.initialize(self.deviceDB)
            self.deviceDB.connect()
        else:
            self.deviceDB = SqliteDatabase(dbPath)
            client_proxy.initialize(self.deviceDB)
            modelsArr = [DeviceDB, PressureTranslationBlock, PhysicalBlock, AIFunctionBlock, TemperatureTranslationBlock, LevelTranslationBlock, FlowTranslationBlock, UnitTable]
            self.deviceDB.connect()
            self.deviceDB.create_tables(modelsArr, safe = True)
