How to use the peewee.BigIntegerField function in peewee

To help you get started, we’ve selected a few peewee examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github timster / peewee-moves / tests / test_tablecreator.py View on Github external
tc.column('datetime', 'col_datetime')
    tc.column('decimal', 'col_decimal')
    tc.column('double', 'col_double')
    tc.column('fixed', 'col_fixed')
    tc.column('float', 'col_float')
    tc.column('int', 'col_int')
    tc.column('integer', 'col_integer')
    tc.column('smallint', 'col_smallint')
    tc.column('smallinteger', 'col_smallinteger')
    tc.column('text', 'col_text')
    tc.column('time', 'col_time')
    tc.column('uuid', 'col_uuid')

    assert isinstance(tc.model.id, peewee.AutoField)
    assert isinstance(tc.model.col_bare, peewee.BareField)
    assert isinstance(tc.model.col_biginteger, peewee.BigIntegerField)
    assert isinstance(tc.model.col_binary, peewee.BlobField)
    assert isinstance(tc.model.col_blob, peewee.BlobField)
    assert isinstance(tc.model.col_bool, peewee.BooleanField)
    assert isinstance(tc.model.col_char, peewee.CharField)
    assert isinstance(tc.model.col_date, peewee.DateField)
    assert isinstance(tc.model.col_datetime, peewee.DateTimeField)
    assert isinstance(tc.model.col_decimal, peewee.DecimalField)
    assert isinstance(tc.model.col_double, peewee.DoubleField)
    assert isinstance(tc.model.col_fixed, peewee.CharField)
    assert isinstance(tc.model.col_float, peewee.FloatField)
    assert isinstance(tc.model.col_int, peewee.IntegerField)
    assert isinstance(tc.model.col_integer, peewee.IntegerField)
    assert isinstance(tc.model.col_smallint, peewee.SmallIntegerField)
    assert isinstance(tc.model.col_smallinteger, peewee.SmallIntegerField)
    assert isinstance(tc.model.col_text, peewee.TextField)
    assert isinstance(tc.model.col_time, peewee.TimeField)
github tgroshon / yelp-data-mining-loader / models.py View on Github external
'stars': (star rating, rounded to half-stars),
      'review_count': review count,
      'categories': [(localized category names)]
      'open': True / False (corresponds to permanently closed, not business hours),
    }
    """
    bid = peewee.PrimaryKeyField()
    business_id = peewee.CharField()  # encrypted ID with letters, numbers, and symbols
    name = peewee.CharField()
    full_address = peewee.CharField()
    city = peewee.CharField()
    state = peewee.CharField(max_length=3)  # XGL
    latitude = peewee.CharField()
    longitude = peewee.CharField()
    stars = peewee.DecimalField()  # star rating rounded to half-stars
    review_count = peewee.BigIntegerField()
    is_open = peewee.BooleanField()
    # neighborhoods = None # list of hood names
    # categories = None # list of category names

    class Meta:
        database = db

class Category(peewee.Model):
    """
    Derived from Business.categories Field.
    """
    id = peewee.PrimaryKeyField()
    business_id = peewee.CharField()
    category_name = peewee.CharField()

    class Meta:
github b1naryth1ef / rowboat / rowboat / models / guild.py View on Github external
return cls.create(
            user_id=member.user.id,
            guild_id=member.guild_id,
            nick=member.nick,
            roles=member.roles,
            mute=member.mute,
            deaf=member.deaf,
        )


@BaseModel.register
class GuildVoiceSession(BaseModel):
    session_id = TextField()
    user_id = BigIntegerField()
    guild_id = BigIntegerField()
    channel_id = BigIntegerField()

    started_at = DateTimeField()
    ended_at = DateTimeField(default=None, null=True)

    class Meta:
        db_table = 'guild_voice_sessions'

        indexes = (
            # Used for conflicts
            (('session_id', 'user_id', 'guild_id', 'channel_id', 'started_at', 'ended_at', ), True),

            (('started_at', 'ended_at', ), False),
        )

    @classmethod
    def create_or_update(cls, before, after):
github FederatedAI / FATE-Cloud / fate_manager / db / db_models.py View on Github external
class FateSiteJobInfo(DataBaseModel):
    institutions = CharField(max_length=128, null=True, help_text='site belongs to institutions')
    party_id = IntegerField(null=True, index=True, help_text='party id')
    site_name = CharField(max_length=50, null=True, help_text='site name')
    role = CharField(max_length=50, index=True)
    job_id = CharField(max_length=64, null=True, help_text='job id')
    job_elapsed = BigIntegerField(null=True)
    roles = JSONField()
    other_party_id = ListField()
    other_institutions = ListField()
    job_type = CharField(max_length=50, index=True)
    job_create_day = CharField(max_length=10, null=True, help_text='job day', index=True)
    job_create_day_date = DateField(null=True, index=True)
    job_create_time = BigIntegerField(null=True)
    job_start_time = BigIntegerField(null=True)
    job_end_time = BigIntegerField(null=True)
    status = CharField(max_length=50, index=True)
    job_info = JSONField()

    class Meta:
        db_table = "t_fate_site_job"
        primary_key = CompositeKey('party_id', 'role', "job_id")


class FateReportInstitution(DataBaseModel):
    id = BigAutoField()
    ds = IntegerField(null=True, help_text='report date')
    institution = CharField(max_length=128, null=True, help_text='institution')
    total = IntegerField(null=True, help_text='total')
    success = IntegerField(null=True, help_text='success')
    running = IntegerField(null=True, help_text='running')
github b1naryth1ef / rowboat / rowboat / models / guild.py View on Github external
except cls.DoesNotExist:
            ge = cls(emoji_id=emoji.id)
            new = True

        ge.guild_id = guild_id or emoji.guild_id
        ge.name = emoji.name
        ge.require_colons = emoji.require_colons
        ge.managed = emoji.managed
        ge.roles = emoji.roles
        ge.save(force_insert=new)
        return ge


@BaseModel.register
class GuildBan(BaseModel):
    user_id = BigIntegerField()
    guild_id = BigIntegerField()
    reason = TextField(null=True)

    class Meta:
        db_table = 'guild_bans'
        primary_key = CompositeKey('user_id', 'guild_id')

    @classmethod
    def ensure(cls, guild, user, reason=None):
        User.ensure(user)
        obj, _ = cls.get_or_create(guild_id=guild.id, user_id=user.id, defaults=dict({
            'reason': reason,
        }))
        return obj
github trifle / twitterresearch / database.py View on Github external
username = peewee.CharField(null=True)

    def last_tweet(self):
        return Tweet.select().where(Tweet.user == self).order_by(Tweet.id.desc())[0]

    def first_tweet(self):
        return Tweet.select().where(Tweet.user == self).order_by(Tweet.id.asc())[0]


class Tweet(BaseModel):

    """
    Tweet model.
    Stores the tweet's unique ID as a primary key along with the user, text and date.
    """
    id = peewee.BigIntegerField(unique=True, primary_key=True)
    user = peewee.ForeignKeyField(User, related_name='tweets', index=True)
    text = peewee.TextField()
    date = peewee.DateTimeField(index=True)
    tags = ManyToManyField(Hashtag)
    urls = ManyToManyField(URL)
    language = peewee.ForeignKeyField(Language, null=True)
    mentions = ManyToManyField(User)
    reply_to_user = peewee.ForeignKeyField(
        User, null=True, index=True, related_name='replies')
    reply_to_tweet = peewee.BigIntegerField(null=True, index=True)
    retweet = peewee.ForeignKeyField(
        'self', null=True, index=True, related_name='retweets')


#
# Helper functions for loading data into the database
github FederatedAI / FATE-Cloud / fate_manager / db / db_models.py View on Github external
site_name = CharField(max_length=128, null=True, help_text='Site Name')
    total = IntegerField(null=True, help_text='total')
    success = IntegerField(null=True, help_text='success')
    running = IntegerField(null=True, help_text='running')
    waiting = IntegerField(null=True, help_text='waiting')
    timeout = IntegerField(null=True, help_text='timeout')
    failed = IntegerField(null=True, help_text='failed')
    canceled = IntegerField(null=True, help_text='failed')

    class Meta:
        db_table = "t_fate_report_site"


class FateSiteInfo(DataBaseModel):
    federated_id = IntegerField(null=True, help_text='federated id')
    site_id = BigIntegerField(null=True, help_text='site id')
    site_name = CharField(max_length=128, help_text='site name')
    federated_organization = CharField(max_length=128, null=True, help_text='Federated Organization')
    party_id = BigIntegerField(null=True, help_text='party id')
    institutions = CharField(max_length=128, null=True, help_text='site belongs to institutions')
    role = SmallIntegerField(default=0, help_text='role,1:guest,2:host')
    app_key = CharField(max_length=64, null=True, help_text='federation key')
    app_secret = CharField(max_length=64, null=True, help_text='Federation secret')
    registration_link = TextField(help_text='registration link')
    network_access_entrances = CharField(null=True, help_text='network access entrances')
    network_access_exits = CharField(null=True, help_text='network access exits')
    fate_version = CharField(max_length=10, null=True, help_text='fate version')
    fate_serving_version = CharField(max_length=10, null=True, help_text='fate serving version')
    component_version = CharField(max_length=512, null=True, help_text='fate component version')
    status = SmallIntegerField(default=0, help_text='site status,1 not joined,2 joined,3 removed')
    deploy_type = SmallIntegerField(default=0, help_text='deploy type ,1k8s,2ansible')
    service_status = SmallIntegerField(default=0, help_text='service status,0 unavailable,1available')
github FederatedAI / FATE-Cloud / fate_manager / db / db_models.py View on Github external
institutions = CharField(max_length=128, null=True, help_text='site belongs to institutions')
    role = SmallIntegerField(default=0, help_text='role,1:guest,2:host')
    app_key = CharField(max_length=64, null=True, help_text='federation key')
    app_secret = CharField(max_length=64, null=True, help_text='Federation secret')
    registration_link = TextField(help_text='registration link')
    network_access_entrances = CharField(null=True, help_text='network access entrances')
    network_access_exits = CharField(null=True, help_text='network access exits')
    fate_version = CharField(max_length=10, null=True, help_text='fate version')
    fate_serving_version = CharField(max_length=10, null=True, help_text='fate serving version')
    component_version = CharField(max_length=512, null=True, help_text='fate component version')
    status = SmallIntegerField(default=0, help_text='site status,1 not joined,2 joined,3 removed')
    deploy_type = SmallIntegerField(default=0, help_text='deploy type ,1k8s,2ansible')
    service_status = SmallIntegerField(default=0, help_text='service status,0 unavailable,1available')
    edit_status = SmallIntegerField(default=-1, help_text='edit status,-1 unkonwn,1 unedit,2 edit')
    read_status = SmallIntegerField(default=-1, help_text='read status,-1 unkonwn,3 read,1agreed ,2rejected')
    activation_time = BigIntegerField(null=True, help_text='activation Time')

    class Meta:
        db_table = "t_fate_site_info"
        primary_key = CompositeKey('party_id', 'federated_id')


class TokenInfo(DataBaseModel):
    user_name = CharField(max_length=50, null=True, help_text='user name')
    token = CharField(null=True, help_text='token')
    expire_time = BigIntegerField(null=True, help_text='expire time')

    class Meta:
        db_table = "t_fate_manager_token_info"
        primary_key = CompositeKey('user_name', 'token')
github b1naryth1ef / rowboat / rowboat / models / message.py View on Github external
'edited_timestamp': obj.edited_timestamp,
            'num_edits': (0 if not obj.edited_timestamp else 1),
            'mentions': list(obj.mentions.keys()),
            'emojis': list(map(int, EMOJI_RE.findall(obj.content))),
            'attachments': [i.url for i in obj.attachments.values()],
            'embeds': [json.dumps(i.to_dict(), default=default_json) for i in obj.embeds],
        }

    @classmethod
    def for_channel(cls, channel):
        return cls.select().where(cls.channel_id == channel.id)


@BaseModel.register
class Reaction(BaseModel):
    message_id = BigIntegerField()
    user_id = BigIntegerField()
    emoji_id = BigIntegerField(null=True)
    emoji_name = TextField()

    class Meta:
        db_table = 'reactions'

        indexes = (
            (('message_id', 'user_id', 'emoji_id', 'emoji_name'), True),
            (('user_id', ), False),
            (('emoji_name', 'emoji_id', ), False),
        )

    @classmethod
    def from_disco_reactors(cls, message_id, reaction, user_ids):
        cls.insert_many([
github b1naryth1ef / rowboat / rowboat / plugins / pickup.py View on Github external
)

TeamSelection = Enum(
    'random',
    'ranked',
    'captains',
)

MapSelection = Enum(
    'random',
)


@BaseModel.register
class PickupGame(BaseModel):
    guild_id = BigIntegerField()
    channel_id = BigIntegerField()
    template = CharField()

    state = IntegerField(default=PickupState.WAITING.index)
    teams = BinaryJSONField(default={})
    results = BinaryJSONField(default={})

    created_at = DateTimeField(default=datetime.utcnow)

    class Meta:
        db_table = 'pickupgames'

    @property
    def all_players(self):
        return sum(self.teams.values(), list())