def setup_database(sqlite_file=':memory:'): from settings import database from models.contribution import Contribution from models.contract import Contract from models.evaluation import Evaluation from models.user import User if database.database != sqlite_file: database.init(sqlite_file) database.connect() database.create_tables([User, Contribution, Contract, Evaluation], safe=True)
def create_tables(): with database: database.create_tables([AuthToken])
class Domain(PwModel): domain = pw.CharField(unique=True, max_length=200) coinbase = pw.CharField(unique=True, max_length=200) used = pw.BooleanField(default=False) class Token(PwModel): name = pw.CharField(max_length=20) symbol = pw.CharField(max_length=20) logo = pw.CharField(null=True) address = pw.CharField(unique=True, max_length=200) total_supply = pw.CharField() decimals = pw.CharField(null=True) is_major = pw.BooleanField(default=False) database.connect() try: database.create_tables([ Admin, Relayer, Token, Domain, ]) except Exception as err: logger.debug(err) logger.info('No need creating tables') database.rollback()
# -*- coding: utf-8 -*- from settings import database from models import CompanySection, CompanySubSection, LegalEntity, WordTable, CollocationTable, ParsedPages database.connect() database.create_tables([ CompanySection, CompanySubSection, LegalEntity, WordTable, CollocationTable, ParsedPages ])
def filtrar_por(**kwargs): select = Licitacao.select() if kwargs['cidade']!='todas': select = select.where(Licitacao.cidade==kwargs['cidade']) if kwargs['estado']!='todos': select = select.where(Licitacao.uf==kwargs['estado']) if kwargs['modalidade']!='todas': select = select.where(Licitacao.modalidade==kwargs['modalidade']) if kwargs['data_entrega']: data1 = formata_data(kwargs['data_entrega'])+' 00:00:00' data2 = formata_data(kwargs['data_entrega'])+' 23:59:59' select = select.where(Licitacao.data_entrega.between(data1, data2)) if kwargs['data_abertura']: data1 = formata_data(kwargs['data_abertura'])+' 00:00:00' data2 = formata_data(kwargs['data_abertura'])+' 23:59:59' select = select.where(Licitacao.data_abertura.between(data1, data2)) if kwargs['termino_proposta'] and kwargs['cotacao_fim']: select = select.where( (Licitacao.termino_proposta>=formata_data(kwargs['termino_proposta'])+' 00:00:00') & (Licitacao.cotacao_fim<=formata_data(kwargs['cotacao_fim'])+' 23:59:59')) if kwargs['objeto']: select = select.where(SQL("match (objeto) against ('{0}')".format(kwargs['objeto']))) select = select.limit(30) print select return select if __name__ == '__main__': database.connect() database.create_tables([Cidade, Estado, Licitacao, Modalidade])
deposit = pw.IntegerField() trade_fee = pw.IntegerField(default=1) from_tokens = ArrayField(pw.CharField, default=[]) to_tokens = ArrayField(pw.CharField, default=[]) logo = pw.CharField(max_length=200, null=True) link = pw.CharField(max_length=255, null=True) resigning = pw.BooleanField(default=False) lock_time = pw.IntegerField(null=True) class Token(PwModel): name = pw.CharField(unique=True, max_length=20) symbol = pw.CharField(unique=True, max_length=20) logo = pw.CharField(null=True) address = pw.CharField(unique=True, max_length=200) total_supply = pw.CharField() is_major = pw.BooleanField(default=False) database.connect() try: database.create_tables([ Admin, Contract, Relayer, Token, ]) except Exception as err: logger.debug(err) logger.info('No need creating tables')