How to use the pypistats.database.Model function in pypistats

To help you get started, we’ve selected a few pypistats 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 crflynn / pypistats.org / pypistats / models / download.py View on Github external
__tablename__ = "recent"

    package = Column(
        db.String(128), primary_key=True, nullable=False, index=True
    )
    # recency, e.g. day, week, month
    category = Column(db.String(8), primary_key=True, nullable=False)
    downloads = Column(db.BigInteger(), nullable=False)

    def __repr__(self):
        return "".format(
            f"{str(self.package)} - {str(self.category)}"
        )


class SystemDownloadCount(Model):
    """Download counts by system."""

    __tablename__ = "system"

    date = Column(db.Date, primary_key=True)
    package = Column(
        db.String(128), primary_key=True, nullable=False, index=True
    )
    # system, e.g. Windows or Linux or Darwin (or null)
    category = Column(db.String(8), primary_key=True, nullable=True)
    downloads = Column(db.Integer(), nullable=False)

    def __repr__(self):
        return "
github crflynn / pypistats.org / pypistats / models / download.py View on Github external
db.String(128), primary_key=True, nullable=False, index=True
    )
    # python_minor version, e.g. 2.7 or 3.6 (or null)
    category = Column(db.String(4), primary_key=True, nullable=True)
    downloads = Column(db.Integer(), nullable=False)

    def __repr__(self):
        return "".format(
            f"{str(self.package)} - {str(self.category)}"
        )
github crflynn / pypistats.org / pypistats / models / download.py View on Github external
"""Package stats tables."""
from pypistats.database import Column
from pypistats.database import Model
from pypistats.extensions import db


class OverallDownloadCount(Model):
    """Overall download counts."""

    __tablename__ = "overall"

    date = Column(db.Date, primary_key=True, nullable=False)
    package = Column(
        db.String(128), primary_key=True, nullable=False, index=True
    )
    # with_mirrors or without_mirrors
    category = Column(db.String(16), primary_key=True, nullable=False)
    downloads = Column(db.Integer(), nullable=False)

    def __repr__(self):
        return "
github crflynn / pypistats.org / pypistats / models / download.py View on Github external
date = Column(db.Date, primary_key=True, nullable=False)
    package = Column(
        db.String(128), primary_key=True, nullable=False, index=True
    )
    # python_major version, 2 or 3 (or null)
    category = Column(db.String(4), primary_key=True, nullable=True)
    downloads = Column(db.Integer(), nullable=False)

    def __repr__(self):
        return "
github crflynn / pypistats.org / pypistats / models / user.py View on Github external
"""User tables."""
import datetime

from flask_login import UserMixin
from sqlalchemy.dialects.postgresql import ARRAY

from pypistats.database import Column
from pypistats.database import Model
from pypistats.database import SurrogatePK
from pypistats.extensions import db


MAX_FAVORITES = 20


class User(UserMixin, SurrogatePK, Model):
    """A user of the app."""

    __tablename__ = 'users'

    uid = Column(db.Integer(), unique=True)
    username = Column(db.String(39), nullable=False)
    avatar_url = Column(db.String(256))
    token = Column(db.String(256))
    created_at = \
        Column(db.DateTime, nullable=False, default=datetime.datetime.utcnow)
    active = Column(db.Boolean(), default=False)
    is_admin = Column(db.Boolean(), default=False)
    favorites = Column(ARRAY(db.String(128), dimensions=1))

    def __init__(self, token, **kwargs):
        """Create instance."""
github crflynn / pypistats.org / pypistats / models / download.py View on Github external
date = Column(db.Date, primary_key=True, nullable=False)
    package = Column(
        db.String(128), primary_key=True, nullable=False, index=True
    )
    # with_mirrors or without_mirrors
    category = Column(db.String(16), primary_key=True, nullable=False)
    downloads = Column(db.Integer(), nullable=False)

    def __repr__(self):
        return "