from peewee import * import datetime from util.util import Log from configuracao.config import Configuracao from util.util import Log config = Configuracao() path = config.config_path() + 'db/dbcliente.db' db = SqliteDatabase(path) class Persistir: @staticmethod def transacoes(nome_servidor, status, descricao): config = Transacoes() config.data_envio = datetime.datetime.now() config.nome_servidor = nome_servidor config.descricao = descricao config.status = status config.save() Log.info('transacao salva') @staticmethod def criar_db(): try: arquivo = open(path) arquivo.close() except FileNotFoundError: Transacoes.create_table() Log.info('criando banco de dados')
from peewee import * import datetime from configuracao.config import Configuracao path_db = Configuracao.config_path() + 'db/nbcliente.db' db = SqliteDatabase(path_db) class BaseModel(Model): class Meta: database = db class Servidor(BaseModel): nome = CharField(max_length=40) host = CharField(max_length=100) porta = IntegerField() qtd_conexoes = IntegerField() def dict_servidor(self): json = { 'nome': nome, 'host': host, 'porta': porta, 'qtd_conexoes': qtd_conexoes } class Backup(BaseModel):