import peewee from .config import config db = peewee.PostgresqlDatabase(config['ttf_postgres_db_name'], user=config['ttf_postgres_user'], host=config['ttf_postgres_host'], password=config['ttf_postgres_password']) class Log(peewee.Model): agent_id = peewee.CharField(null=False) timestamp = peewee.BigIntegerField(null=False) tag = peewee.CharField() log = peewee.CharField(null=False) class Meta: database = db db_table = 'logs' class Credential(peewee.Model): agent_id = peewee.CharField(null=False) timestamp = peewee.BigIntegerField(null=False) username = peewee.CharField(null=False) secret = peewee.CharField(null=False) type = peewee.CharField(null=False) service = peewee.CharField(null=True) class Meta: database = db db_table = 'credentials' class File(peewee.Model): agent_id = peewee.CharField(null=False) timestamp = peewee.BigIntegerField(null=False) name = peewee.CharField(null=False) path = peewee.CharField(null=True) data = peewee.CharField(null=False) class Meta: database = db db_table = 'files' class Agent(peewee.Model): agent_id = peewee.CharField(null=False) last_log = peewee.BigIntegerField(null=False) logs = peewee.BigIntegerField(null=False, default=0) class Meta: database = db db_table = 'agents' db.create_tables([Log, Agent, Credential, File])