コード例 #1
0
    class EventModel(peewee.Model):
        uuid = peewee.UUIDField(default=uuid.uuid4,
                                index=True,
                                primary_key=True)

        event_type = peewee.CharField(index=True, null=True)
        event_type_version = peewee.CharField(index=True, null=True)
        cloud_events_version = peewee.CharField(index=True, null=True)
        source = peewee.CharField(index=True, null=True)
        event_id = peewee.CharField(index=True, null=True)
        event_time = peewee.CharField(index=True, null=True)
        schema_url = peewee.CharField(index=True, null=True)
        content_type = peewee.CharField(index=True, null=True)

        event_data = peewee.TextField()
        data = peewee.TextField()

        task_id = peewee.UUIDField(index=True, unique=True)
        task_application_name = peewee.CharField(index=True)
        task_name = peewee.CharField(index=True)
        task_status = peewee.CharField(index=True)

        exc_type = peewee.CharField(null=True)
        exc_value = peewee.CharField(null=True)
        exc_traceback = peewee.TextField()

        created = peewee.DateTimeField(default=datetime.datetime.now,
                                       index=True)
        updated = peewee.DateTimeField(default=datetime.datetime.now,
                                       index=True)
        deleted = peewee.DateTimeField(index=True, null=True)

        class Meta(object):
            database = db
コード例 #2
0
class ToDo(BaseModel):
    uuid = pw.UUIDField(primary_key=True, default=uuid.uuid4)
    name = pw.TextField()
    status = pw.BooleanField()

    def to_json(self):
        return {"uuid": self.uuid, "name": self.name, "status": self.status}
コード例 #3
0
ファイル: Ticker.py プロジェクト: venkiiee/jesse
class Ticker(peewee.Model):
    id = peewee.UUIDField(primary_key=True)
    # timestamp in milliseconds
    timestamp = peewee.BigIntegerField()
    # the latest trades price
    last_price = peewee.FloatField()
    # the trading volume in the last 24 hours
    volume = peewee.FloatField()
    # the highest price in the last 24 hours
    high_price = peewee.FloatField()
    # the lowest price in the last 24 hours
    low_price = peewee.FloatField()
    symbol = peewee.CharField()
    exchange = peewee.CharField()

    class Meta:
        database = db
        indexes = ((('timestamp', 'exchange', 'symbol'), True), )

    def __init__(self, attributes=None, **kwargs):
        peewee.Model.__init__(self, attributes=attributes, **kwargs)

        if attributes is None:
            attributes = {}

        for a in attributes:
            setattr(self, a, attributes[a])
コード例 #4
0
ファイル: test_producer.py プロジェクト: salekseev/telstar
class Events(peewee.Model):
    msg_uid = peewee.UUIDField(default=uuid.uuid4)
    topic = peewee.CharField()
    data = JSONField()

    class Meta:
        database = db
コード例 #5
0
ファイル: Trade.py プロジェクト: jesse-ai/jesse
class Trade(peewee.Model):
    id = peewee.UUIDField(primary_key=True)
    # timestamp in milliseconds
    timestamp = peewee.BigIntegerField()

    price = peewee.FloatField()

    buy_qty = peewee.FloatField()
    sell_qty = peewee.FloatField()

    buy_count = peewee.IntegerField()
    sell_count = peewee.IntegerField()

    symbol = peewee.CharField()
    exchange = peewee.CharField()

    class Meta:
        from jesse.services.db import database

        database = database.db
        indexes = ((('timestamp', 'exchange', 'symbol'), True), )

    def __init__(self, attributes: dict = None, **kwargs) -> None:
        peewee.Model.__init__(self, attributes=attributes, **kwargs)

        if attributes is None:
            attributes = {}

        for a, value in attributes.items():
            setattr(self, a, value)
コード例 #6
0
ファイル: models.py プロジェクト: NaleRaphael/qnote
class Note(BaseModel):
    id = pw.AutoField()
    uuid = pw.UUIDField()
    title = pw.CharField(max_length=256)
    create_time = pw.TimestampField()
    update_time = pw.TimestampField()
    content = pw.TextField()
コード例 #7
0
class Trade(peewee.Model):
    """

    """
    id = peewee.UUIDField(primary_key=True)
    # timestamp in milliseconds
    timestamp = peewee.BigIntegerField()

    price = peewee.FloatField()

    buy_qty = peewee.FloatField()
    sell_qty = peewee.FloatField()

    buy_count = peewee.IntegerField()
    sell_count = peewee.IntegerField()

    symbol = peewee.CharField()
    exchange = peewee.CharField()

    class Meta:
        database = db
        indexes = ((('timestamp', 'exchange', 'symbol'), True), )

    def __init__(self, attributes=None, **kwargs):
        peewee.Model.__init__(self, attributes=attributes, **kwargs)

        if attributes is None:
            attributes = {}

        for a in attributes:
            setattr(self, a, attributes[a])
コード例 #8
0
class Candle(peewee.Model):
    id = peewee.UUIDField(primary_key=True)
    timestamp = peewee.BigIntegerField()
    open = peewee.FloatField()
    close = peewee.FloatField()
    high = peewee.FloatField()
    low = peewee.FloatField()
    volume = peewee.FloatField()
    symbol = peewee.CharField()
    exchange = peewee.CharField()

    # partial candles: 5 * 1m candle = 5m candle while 1m == partial candle
    is_partial = True

    class Meta:
        database = db
        indexes = ((('timestamp', 'exchange', 'symbol'), True), )

    def __init__(self, attributes=None, **kwargs) -> None:
        peewee.Model.__init__(self, attributes=attributes, **kwargs)

        if attributes is None:
            attributes = {}

        for a in attributes:
            setattr(self, a, attributes[a])
コード例 #9
0
ファイル: 008_models.py プロジェクト: indietyp/IoP
def migrate(migrator, database, fake=False, **kwargs):
    """Write your migrations here."""

    migrator.add_fields(
        'person',

        uuid=pw.UUIDField(default=uuid.uuid4))
コード例 #10
0
ファイル: 001_migration.py プロジェクト: aoirint/fastauth
    class EmailUser(pw.Model):
        _id = pw.UUIDField(column_name='id', primary_key=True)
        _email = pw.CharField(column_name='email', max_length=255, unique=True)
        _password = pw.CharField(column_name='password', max_length=255)

        class Meta:
            table_name = "fastauth_emailuser"
コード例 #11
0
class User(BaseModel):
    """User Model for the SQL db"""

    user_id = pw.UUIDField(primary_key=True, unique=True)

    username = pw.CharField(unique=True, null=False, max_length=50)

    password = pw.CharField(null=False, max_length=130)

    first_name = pw.CharField(null=True, max_length=100)

    last_name = pw.CharField(null=True, max_length=100)

    role = pw.SmallIntegerField(null=False,
                                default=0)  # 0 - Analysts, 1 - Managers

    ip_address = pw.CharField(null=True, default=None, max_length=50)

    last_login_time = pw.DateTimeField(null=True, default=None)

    created_at = pw.DateTimeField(default=datetime.datetime.now)

    last_modified_at = pw.DateTimeField(null=True, default=None)
    """
        Meta definition for the table
    """
    class Meta:
        table_name = SETTINGS['sql']['tables']['users']
コード例 #12
0
class Quiz(BaseModelP):
    uuid = pw.UUIDField(primary_key=True)
    name = pw.CharField()
    public = pw.BooleanField()
    onlynext = pw.BooleanField()
    timing = pw.BooleanField()
    random = pw.BooleanField()
    start_time = pw.DateTimeField(null=True)
    end_time = pw.DateTimeField(null=True)
    creator = pw.ForeignKeyField(User, backref="created_quizzes")

    def teacher_name(self):
        return self.creator.name

    def question_count(self):
        return Question.select().where(Question.quiz == self).count()

    def start_time_shamsi(self):
        if self.start_time == None:
            return 'نامشخص'
        cal = calverter.Calverter()
        jd = cal.gregorian_to_jd(self.start_time.year, self.start_time.month, self.start_time.day)
        date_shamsi = "/".join([str(i) for i in cal.jd_to_jalali(jd)])
        date_time = str(self.start_time.hour) + ":" + str(self.start_time.minute) + ' ' + date_shamsi
        return date_time

    def end_time_shamsi(self):
        if self.end_time == None:
            return 'نامشخص'

        cal = calverter.Calverter()
        jd = cal.gregorian_to_jd(self.end_time.year, self.end_time.month, self.end_time.day)
        date_shamsi = "/".join([str(i) for i in cal.jd_to_jalali(jd)])
        date_time = str(self.end_time.hour) + ":" + str(self.end_time.minute) + ' ' + date_shamsi
        return date_time
コード例 #13
0
class Exchange(BaseModel):
    uuid = peewee.UUIDField(primary_key=True, unique=True)
    name = peewee.CharField(max_length=64)
    enname = peewee.CharField(max_length=128)
    symbol = peewee.CharField(max_length=128)
    currency = peewee.ForeignKeyField(Currency,
                                      backref='exchanges')  # 交易所使用何种货币
コード例 #14
0
class Company(BaseModel):
    uuid = peewee.UUIDField(primary_key=True, unique=True)
    name = peewee.CharField(max_length=256)  # 公司名
    enname = peewee.CharField(max_length=256)  # 公司英文名
    market = peewee.CharField(max_length=128, null=True)  # 上市市场
    list_date = peewee.DateField(null=True)  # 上市日期
    init_price = peewee.CharField(max_length=128, null=True)  # 发行价格
    lead_underwriter = peewee.CharField(max_length=256, null=True)  # 主承销商
    create_date = peewee.DateField(null=True)  # 成立日期
    reg_capital = peewee.IntegerField(null=True)  # 注册资本(元)
    organization_type = peewee.CharField(max_length=128, null=True)  # 机构类型
    organization_form = peewee.CharField(max_length=128, null=True)  # 组织形式

    board_secretary = peewee.CharField(max_length=128, null=True)  # 董事会秘书
    board_secretary_telephone = peewee.CharField(max_length=128,
                                                 null=True)  # 董秘电话
    board_secretary_fax = peewee.CharField(max_length=128, null=True)  # 董秘传真
    board_secretary_mail = peewee.CharField(max_length=128,
                                            null=True)  # 董秘电子邮件

    company_telephone = peewee.CharField(max_length=128, null=True)  # 公司电话
    company_fax = peewee.CharField(max_length=128, null=True)  # 公司传真
    company_mail = peewee.CharField(max_length=128, null=True)  # 公司邮件
    company_website = peewee.CharField(max_length=128, null=True)  # 公司网站

    zip_code = peewee.CharField(max_length=64, null=True)  # 公司邮编
    register_address = peewee.CharField(max_length=256, null=True)  # 注册地址
    office_address = peewee.CharField(max_length=256, null=True)  # 办公地址
    description = peewee.TextField(null=True)  # 公司简介
    business_scope = peewee.TextField(null=True)  # 经营范围
コード例 #15
0
class KDataDay(BaseModel):
    uuid = peewee.UUIDField(primary_key=True, unique=True)
    date = peewee.DateField(index=True)  # 日期
    equity = peewee.ForeignKeyField(Equities, backref='kdata',
                                    index=True)  # 股票代码
    open_price = peewee.DecimalField(max_digits=14, decimal_places=3)  # 开盘价
    high_price = peewee.DecimalField(max_digits=14, decimal_places=3)  # 最高价
    low_price = peewee.DecimalField(max_digits=14, decimal_places=3)  # 最低价
    close_price = peewee.DecimalField(max_digits=14, decimal_places=3)  # 今收盘价
    volume = peewee.IntegerField()  # 成交数量
    amount = peewee.DecimalField(max_digits=14, decimal_places=3)  # 成交金额
    adjustflag = peewee.IntegerField()  # 复权状态, 复权类型,默认不复权:1;2:后复权;3:前复权
    turn = peewee.DecimalField(max_digits=12, decimal_places=6,
                               null=True)  # 换手率
    tradestatus = peewee.IntegerField(null=True)  # 交易状态 (1:正常交易 0:停牌)
    pctChg = peewee.DecimalField(max_digits=12, decimal_places=6,
                                 null=True)  # 涨跌幅
    peTTM = peewee.DecimalField(max_digits=12, decimal_places=6,
                                null=True)  # 滚动市盈率
    pbMRQ = peewee.DecimalField(max_digits=12, decimal_places=6,
                                null=True)  # 市净率
    psTTM = peewee.DecimalField(max_digits=12, decimal_places=6,
                                null=True)  # 滚动市销率
    pcfNcfTTM = peewee.DecimalField(max_digits=12, decimal_places=6,
                                    null=True)  # 滚动市现率
    isST = peewee.IntegerField(null=True)  # 是否ST股,1是,0否
コード例 #16
0
class Equities(BaseModel):
    uuid = peewee.UUIDField(primary_key=True, unique=True)
    # 基本信息
    exchange = peewee.ForeignKeyField(Exchange, backref='equities',
                                      null=True)  # 所属市场
    market = peewee.ForeignKeyField(Market, backref='equities',
                                    null=True)  # 所属板块
    symbol = peewee.CharField(max_length=128)  # 股票代码
    name = peewee.CharField(max_length=64)  # 股票名称
    area = peewee.CharField(max_length=64, null=True)  # 所在地域
    industry = peewee.ForeignKeyField(ShenWanIndustry,
                                      backref='equities',
                                      null=True)
    list_status = peewee.CharField(max_length=16)  # 上市信息 L上市 D退市 P暂停上市
    list_date = peewee.DateField(null=True)  # 上市日期
    delist_date = peewee.DateField(null=True)  # 退市日期

    # 公司信息
    company = peewee.ForeignKeyField(Company, backref='equities',
                                     null=True)  # 公司详细信息
    company_name = peewee.CharField(max_length=128)  # 公司名称
    main_business = peewee.CharField(max_length=512)  # 主营业务
    telephone = peewee.CharField(max_length=64, null=True)  # 电话
    fax = peewee.CharField(max_length=64, null=True)  # 传真
    setup_date = peewee.DateField(null=True)  # 成立日期
    chairman = peewee.CharField(max_length=128, null=True)  # 法人代表
    manager = peewee.CharField(max_length=128, null=True)  # 总经理
    reg_capital = peewee.IntegerField(null=True)  # 注册资本(元)
コード例 #17
0
class DailyBalance(peewee.Model):
    id = peewee.UUIDField(primary_key=True)
    timestamp = peewee.BigIntegerField()
    identifier = peewee.CharField(null=True)
    exchange = peewee.CharField()
    asset = peewee.CharField()
    balance = peewee.FloatField()

    class Meta:
        from jesse.services.db import database

        database = database.db
        indexes = (
            (('identifier', 'exchange', 'timestamp', 'asset'), True),
            (('identifier', 'exchange'), False),
        )

    def __init__(self, attributes: dict = None, **kwargs) -> None:
        peewee.Model.__init__(self, attributes=attributes, **kwargs)

        if attributes is None:
            attributes = {}

        for a, value in attributes.items():
            setattr(self, a, value)
コード例 #18
0
class CollectedDataByOrganization(DomainObject):
    '''CollectedDataByOrganization. Доменный класс.\n
    collection_id: UUIDField - суррогатный ключ\n
    url: TextField - текстовое поле для хранения URL организации-сайта\n
    resources: BigBitField - байтовое поле, для хранения больших данных'''
    collection_id = peewee.UUIDField(default=uuid.uuid4)
    url = peewee.TextField()
    resources = peewee.BigBitField()
コード例 #19
0
class User(BaseModel):
    """
    Model represents users. Needs to display
    users info in chat rooms.
    """
    id = models.UUIDField(unique=True, primary_key=True)
    email = models.CharField(unique=True)
    name = models.CharField()
コード例 #20
0
class Person(BaseModel):
    uuid = peewee.UUIDField(primary_key=True, unique=True)
    name = peewee.CharField(max_length=64)  # 姓名
    gender = peewee.CharField(max_length=32)  # 性别
    birth = peewee.CharField(max_length=32, null=True)  # 出生日期
    education = peewee.CharField(max_length=32, null=True)  # 学历
    nationality = peewee.CharField(max_length=64, null=True)  # 国籍
    resume = peewee.TextField(null=True)  # 简历
コード例 #21
0
ファイル: ssb.py プロジェクト: freespace/ssb
class BackupLog(LogDBModel):
  uuid = pw.UUIDField()
  version = pw.IntegerField()
  host = pw.CharField()
  timestamp = pw.DateTimeField()
  backup_set_uuid = pw.UUIDField(null=True)
  db_path = None

  def __str__(self):
    return f'BackupLog(uuid={self.uuid} host={self.host} ts={self.timestamp})'

  @classmethod
  def new(cls):
    db_id = uuid4()
    db_name = str(db_id)
    db_path = op.join('.', f'{LOG_DB_PREFIX}-{db_name}.sqlite')
    LOG_DB.init(db_path)
    LOG_DB.create_tables([BackupLog, BackupLogEntry])

    backup_log = BackupLog(uuid=db_id,
                           version=1,
                           host=gethostname(),
                           timestamp=datetime.utcnow())

    backup_log.save()
    backup_log.db_path = db_path
    print('Created new log', backup_log)
    return backup_log

  @classmethod
  def load(cls, db_path):
    LOG_DB.init(db_path)
    backup_log = BackupLog.get(id=1)
    backup_log.db_path = db_path

    print('Using existing log', backup_log)
    return backup_log

  def log(self, file_transaction, storage):
    entry = BackupLogEntry(source_path=file_transaction.source_path,
                           dest_path=file_transaction.dest_path,
                           size=file_transaction.size,
                           timestamp=file_transaction.timestamp,
                           sha256hash=file_transaction.sha256hash,
                           storage_uuid=storage.uuid)
    entry.save()
コード例 #22
0
ファイル: sync.py プロジェクト: leifdenby/twsync
class TodoistTaskWarrierSyncModel(peewee.Model):
    taskwarrier = peewee.UUIDField()
    todoist = peewee.IntegerField(unique=True)
    created_on = peewee.DateTimeField(default=datetime.datetime.now)
    completed = peewee.BooleanField(default=False)

    class Meta:
        database = db
コード例 #23
0
ファイル: 012_models.py プロジェクト: indietyp/IoP
 class DayNightTime(pw.Model):
     uuid = pw.UUIDField()
     start = pw.IntegerField(default=900)
     stop = pw.IntegerField(default=2400)
     display = pw.BooleanField(default=False)
     ledbar = pw.BooleanField(default=False)
     generalleds = pw.BooleanField(default=False)
     notification = pw.BooleanField(default=False)
コード例 #24
0
ファイル: 011_models.py プロジェクト: indietyp/IoP
def migrate(migrator, database, fake=False, **kwargs):
    """Write your migrations here."""

    # migrator.add_not_null('meshmessage', 'created_at')

    migrator.add_fields(
        'sensorsatisfactionvalue',

        uuid=pw.UUIDField(default=uuid4))
コード例 #25
0
class BaseModel(db_wrapper.Model):
    id = peewee.UUIDField(primary_key=True, default=uuid.uuid4)
    create_time = peewee.DateTimeField(default=datetime.datetime.now,
                                       verbose_name="创建时间")
    modify_time = peewee.DateTimeField(default=datetime.datetime.now,
                                       verbose_name="修改时间")
    is_del = peewee.BooleanField(default=False, verbose_name='是否删除', null=True)

    common_fields = ("id", "create_time", "modify_time")
コード例 #26
0
class Submission(BaseModel):
    """Survey submission model.

    Uses a UUID for the ID instead of an integer sequence so that survey
    submissions cannot be linked to user hashes."""
    id = peewee.UUIDField(default=uuid.uuid4, primary_key=True)
    form = peewee.TextField()
    time = peewee.DateTimeField(default=datetime.datetime.now)
    version = peewee.IntegerField()
コード例 #27
0
class Tenure(BaseModel):
    uuid = peewee.UUIDField(primary_key=True, unique=True)
    person = peewee.ForeignKeyField(Person, backref='tenure')  # 高管
    company = peewee.ForeignKeyField(Company, backref='tenure')  # 任职公司
    position = peewee.CharField(max_length=64)  # 职务
    appointment_date = peewee.DateField(null=True)  # 任职日期
    departure_date = peewee.DateField(null=True)  # 离职日期
    remuneration = peewee.IntegerField(null=True)  # 报酬(元)
    period = peewee.IntegerField(null=True)  # 第几届
コード例 #28
0
ファイル: model.py プロジェクト: triplekill/deeptracy
class BaseModel(signals.Model):
    """
    BaseModel is an abstract model with options affecting all its
    children.
    """
    id = peewee.UUIDField(primary_key=True, default=uuid.uuid4)

    class Meta:
        database = Config.POSTGRES
コード例 #29
0
class MiddleFile(BaseModel):
    username = peewee.CharField(max_length=20)
    spider_task_id = peewee.UUIDField(unique=True)
    url = peewee.CharField(max_length=256)
    filename = peewee.CharField(unique=True, max_length=128)
    ext = peewee.CharField(max_length=8, default='.html')
    file_utility = peewee.CharField(max_length=2)

    class Meta:
        db_table = 'aegis_middle_file'
コード例 #30
0
ファイル: ssb.py プロジェクト: freespace/ssb
class BackupSet(StorageDBModel):
  backup_dirs = pw.CharField(max_length=1024)
  timestamp = pw.DateTimeField()
  uuid = pw.UUIDField()
  name = pw.CharField(null=True)
  comment = pw.TextField(null=True)
  host = pw.CharField()
  version = pw.IntegerField()
  sequence_number = pw.IntegerField()
  is_final = pw.BooleanField()