示例#1
0
class CharacterQuestState(Base):
    __tablename__ = 'character_quest_state'

    guid = Column(ForeignKey('characters.guid', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True, nullable=False, server_default=text("0"))
    quest = Column(INTEGER(11), primary_key=True, nullable=False, server_default=text("0"))
    state = Column(INTEGER(11), nullable=False, server_default=text("0"))
    rewarded = Column(TINYINT(1), nullable=False, server_default=text("0"))
    explored = Column(TINYINT(1), nullable=False, server_default=text("0"))
    timer = Column(BIGINT(20), nullable=False, server_default=text("0"))
    mobcount1 = Column(INTEGER(11), nullable=False, server_default=text("0"))
    mobcount2 = Column(INTEGER(11), nullable=False, server_default=text("0"))
    mobcount3 = Column(INTEGER(11), nullable=False, server_default=text("0"))
    mobcount4 = Column(INTEGER(11), nullable=False, server_default=text("0"))
    itemcount1 = Column(INTEGER(11), nullable=False, server_default=text("0"))
    itemcount2 = Column(INTEGER(11), nullable=False, server_default=text("0"))
    itemcount3 = Column(INTEGER(11), nullable=False, server_default=text("0"))
    itemcount4 = Column(INTEGER(11), nullable=False, server_default=text("0"))
    reward_choice = Column(INTEGER(11), nullable=False, server_default=text("0"))

    character = relationship('Character')
示例#2
0
class PromoterStatistic(db.Model):
    __tablename__ = 'promoter_statistics'

    id = Column(String(36), primary_key=True)
    user_id = Column(String(36), comment='用户 id')
    role_type = Column(TINYINT(4), comment='角色类型 1 为推广商 2 位推广经理')
    daily_trading_volume = Column(DECIMAL(16, 2), comment='日交易量')
    monthly_transaction_volume = Column(DECIMAL(16, 2), comment='月交易量')
    total_transaction_volume = Column(DECIMAL(16, 2), comment='总交易量')
    daily_total_commission = Column(DECIMAL(16, 2), comment='日的总佣金')
    brokerage_cost_per_day = Column(DECIMAL(16, 2), comment='日的券商成本')
    daily_remaining_commission = Column(DECIMAL(16, 2), comment='日的剩余佣金')
    total_monthly_commission = Column(DECIMAL(16, 2), comment='月的总佣金')
    brokerage_cost_per_month = Column(DECIMAL(16, 2), comment='月的券商成本')
    months_remaining_commission = Column(DECIMAL(16, 2), comment='月的剩余佣金')
    total_total_commission = Column(DECIMAL(16, 2), comment='总的总佣金')
    total_brokerage_cost = Column(DECIMAL(16, 2), comment='总的券商成本')
    total_remaining_commission = Column(DECIMAL(16, 2), comment='总的剩余佣金')
    create_time = Column(BIGINT(20), comment='创建时间')
    creation_time_int = Column(INTEGER(11), comment='创建时间 yyMMdd')
示例#3
0
class PmsProductAttributeValue(Base):
    __tablename__ = 'pms_product_attribute_value'
    __table_args__ = {'comment': '存储产品参数信息的表'}

    id = Column(BIGINT(20), primary_key=True)
    product_id = Column(ForeignKey('pms_product.id',
                                   ondelete='RESTRICT',
                                   onupdate='RESTRICT'),
                        index=True)
    product_attribute_id = Column(ForeignKey('pms_product_attribute.id',
                                             ondelete='RESTRICT',
                                             onupdate='RESTRICT'),
                                  index=True)
    value = Column(VARCHAR(64),
                   nullable=False,
                   comment='手动添加规格或参数的值,参数单值,规格有多个时以逗号隔开')
    picture = Column(VARCHAR(255))

    product_attribute = relationship('PmsProductAttribute')
    product = relationship('PmsProduct')
示例#4
0
class Benchmark_Returns_Generated(Base):
    __tablename__ = 'benchmark_daily'
    __table_args__ = (UniqueConstraint('ticker', 'date', name='constraint_1'),
                      UniqueConstraint('benchmark_id',
                                       'date',
                                       name='constraint_2'),
                      ForeignKeyConstraint(['ticker'],
                                           ['benchmark_static.ticker']),
                      ForeignKeyConstraint(['benchmark_id'],
                                           ['benchmark_static.benchmark_id']))
    benchmark_id = Column('benchmark_id',
                          BIGINT(unsigned=True),
                          primary_key=True)
    ticker = Column('ticker', String(16), nullable=False)
    logreturn = Column('logreturn', Float)
    percent = Column('percent', Float)
    date = Column('date', Date, primary_key=True)

    def __repr__(self):
        return "Debug: Benchmark_Returns_Generated"
示例#5
0
class Page(db.Model):
    __tablename__ = 'pages'

    page_id = Column(BIGINT(20), primary_key=True)
    notebook_id = Column(ForeignKey('notebooks.notebook_id'),
                         nullable=False,
                         index=True)
    position = Column(INTEGER(11), nullable=False)
    title = Column(String(80))
    content = Column(LONGTEXT)

    notebook = relationship('Notebook')

    @classmethod
    def find_by_id(cls, id: int):
        return cls.query.filter_by(page_id=id).first()

    def save_to_db(self):
        if not self.position:
            count = self.query.filter_by(
                notebook_id=self.notebook_id).count() + 1
            self.position = count
        db.session.add(self)
        db.session.commit()

    def delete_from_db(self):
        pages = self.query.filter(Page.position > self.position).all()
        for page in pages:
            page.position -= 1
            page.save_to_db()

        db.session.delete(self)
        db.session.commit()

    @classmethod
    def find_all(cls):
        return cls.query.all()

    @classmethod
    def find_all_pages_of_notebook(cls, id: int):
        return cls.query.filter_by(notebook_id=id).all()
示例#6
0
class User(db.Model):
    __tablename__ = 'User'
    __table_args__ = {
        'mysql_engine': 'InnoDB',
        'mysql_charset': 'utf8',
        'extend_existing': True
    }

    id = db.Column(BIGINT(20, unsigned=True), primary_key=True, index=True)

    name = db.Column(VARCHAR(128))

    username = db.Column(VARCHAR(128), unique=True)

    email = db.Column(VARCHAR(128))

    phone = db.Column(VARCHAR(20))

    password = db.Column(VARCHAR(128))

    birthday = db.Column(DATETIME())

    joinDate = db.Column(DATETIME())

    authority = db.Column(VARCHAR(20))

    def as_dict(self):
        dict = {}
        for c in self.__table__.columns:
            if c.name == "password":
                continue
            if c.name == "birthday":
                tmp = getattr(self, c.name).strftime("%Y-%m-%d")
                dict[c.name] = tmp
            else:
                if c.name == "joinDate":
                    tmp = getattr(self, c.name).__str__()
                    dict[c.name] = tmp
                else:
                    dict[c.name] = getattr(self, c.name)
        return dict
示例#7
0
class UserFriendNotice(Base):
    __tablename__ = 'user_friend_notice'

    id = Column(BIGINT(20), primary_key=True, comment='主键')
    msgtype = Column(Enum('apply_friend', 'system'), comment='消息类型')
    related_id = Column(BIGINT(20), comment='关联业务主键')
    message = Column(String(200), server_default=text("''"), comment='附加消息')
    from_user_id = Column(BIGINT(20), comment='User 用户ID 消息发送者 0表示为系统消息')
    to_user_id = Column(BIGINT(20), comment='消息接收者 User 用户ID')
    read_at = Column(BIGINT(13), comment='读消息UTC时间')
    status = Column(TINYINT(1),
                    nullable=False,
                    server_default=text("'0'"),
                    comment='状态:( 0 未读;1 已读 11 接受 12 拒绝请求)')
    created_at = Column(BIGINT(13), comment='创建记录UTC时间')
示例#8
0
class OmsOrder(Base):
    __tablename__ = 'oms_order'
    __table_args__ = {'comment': '订单表'}

    id = Column(BIGINT(20), primary_key=True, comment='订单id')
    member_id = Column(ForeignKey('ums_member.id',
                                  ondelete='RESTRICT',
                                  onupdate='RESTRICT'),
                       nullable=False,
                       index=True)
    order_sn = Column(VARCHAR(64), comment='订单编号')
    create_time = Column(DateTime, comment='提交时间')
    member_username = Column(VARCHAR(64), comment='用户帐号')
    total_amount = Column(DECIMAL(10, 2), comment='订单总金额')
    pay_amount = Column(DECIMAL(10, 2), comment='应付金额(实际支付金额)')
    freight_amount = Column(DECIMAL(10, 2), comment='运费金额')
    pay_type = Column(INTEGER(11), comment='支付方式:0->未支付;1->支付宝;2->微信')
    source_type = Column(INTEGER(11), comment='订单来源:0->PC订单;1->app订单')
    status = Column(INTEGER(11),
                    comment='订单状态:1->待付款;2->待发货;3->已发货;4->待评价;5->已评价;6->已关闭')
    delivery_company = Column(VARCHAR(64), comment='物流公司(配送方式)')
    delivery_sn = Column(VARCHAR(64), comment='物流单号')
    receiver_name = Column(VARCHAR(100), nullable=False, comment='收货人姓名')
    receiver_phone = Column(VARCHAR(32), nullable=False, comment='收货人电话')
    receiver_post_code = Column(VARCHAR(32), comment='收货人邮编')
    receiver_province = Column(VARCHAR(32), comment='省份/直辖市')
    receiver_city = Column(VARCHAR(32), comment='城市')
    receiver_region = Column(VARCHAR(32), comment='区')
    receiver_detail_address = Column(VARCHAR(200), comment='详细地址')
    note = Column(VARCHAR(500), comment='订单备注')
    confirm_status = Column(INTEGER(11), comment='确认收货状态:0->未确认;1->已确认')
    delete_status = Column(INTEGER(11),
                           nullable=False,
                           server_default=text("'0'"),
                           comment='删除状态:0->未删除;1->已删除')
    payment_time = Column(DateTime, comment='支付时间')
    delivery_time = Column(DateTime, comment='发货时间')
    receive_time = Column(DateTime, comment='确认收货时间')
    comment_time = Column(DateTime, comment='评价时间')

    member = relationship('UmsMember')
示例#9
0
文件: Model.py 项目: Jarsen136/chat
class HtMsg(Base):
    __tablename__ = 'ht_msg'

    id = Column(INTEGER(11), primary_key=True, comment='编号')
    name = Column(VARCHAR(255),
                  nullable=False,
                  server_default=text("''"),
                  comment='名字')
    msg = Column(TEXT, nullable=False, comment='聊天内容')
    room_uuid = Column(VARCHAR(255),
                       nullable=False,
                       server_default=text("''"),
                       comment='房间唯一编号')
    user_id = Column(INTEGER(11), nullable=False, comment='用户编号')
    type = Column(TINYINT(2), nullable=False, comment='类型')
    head_img = Column(VARCHAR(255),
                      nullable=False,
                      server_default=text("''"),
                      comment='头像')
    created_at = Column(BIGINT(14), nullable=False, comment='创建时间')
    send_status = Column(TINYINT(2), nullable=False, comment='发送状态')
示例#10
0
文件: role.py 项目: panpanYU/blog
class Role(db.Model):
    __bind_key__ = 'mysql_bind'
    __tablename__ = 'role'

    id = db.Column('id',
                   BIGINT(unsigned=True),
                   nullable=False,
                   autoincrement=True,
                   primary_key=True)
    name = db.Column('name', db.String(128), nullable=False, comment='角色名称')
    op_user = db.Column('op_user', db.BIGINT, nullable=False, comment='操作人')
    ctime = db.Column('ctime',
                      db.DateTime,
                      nullable=False,
                      default=datetime.now(),
                      comment='创建时间')
    mtime = db.Column('mtime',
                      db.DateTime,
                      nullable=False,
                      default=datetime.now(),
                      comment='更新时间')
示例#11
0
class Transaction(Base, Structure, metaclass=FinalMeta):
    # https://api.blockcypher.com/v1/eth/main/txs (ok)
    __tablename__ = 'tx'
    __fields__ = [
        'hash', 'file_timestamp', 'received', 'gas_limit', 'gas_price', 'fees',
        'double_spend'
    ]
    id = Column(Integer, primary_key=True)
    file_timestamp = Column(Integer)
    hash = Column(String(64), unique=True)
    received = Column(Integer, nullable=False)
    gas_limit = Column(Integer, nullable=True)
    gas_price = Column(Numeric, nullable=True)
    fees = Column(BIGINT(unsigned=True), nullable=True)
    double_spend = Column(Boolean, nullable=True)
    gas_used = Column(Integer, nullable=True)
    bck_id = Column(Integer, ForeignKey('block.height'), nullable=True)

    # For passing position arguments to the creation of the Transaction object
    def __init__(self, *args, **kwargs):
        Structure.__init__(self, *args, **kwargs)
示例#12
0
class PmsComment(Base):
    __tablename__ = 'pms_comment'
    __table_args__ = {'comment': '商品评价表'}

    id = Column(BIGINT(20), primary_key=True)
    product_id = Column(ForeignKey('pms_product.id'), index=True)
    member_nick_name = Column(VARCHAR(255))
    product_name = Column(VARCHAR(255))
    star = Column(INTEGER(11), comment='评价星数:0->5')
    create_time = Column(DateTime)
    show_status = Column(INTEGER(11))
    product_attribute = Column(VARCHAR(255), comment='购买时的商品属性')
    collect_count = Column(INTEGER(11))
    read_count = Column(INTEGER(11))
    content = Column(TEXT)
    pics = Column(VARCHAR(1000), comment='上传图片地址,以逗号隔开')
    member_icon = Column(VARCHAR(255), comment='评论用户头像')
    member_id = Column(ForeignKey('ums_member.id'), index=True)

    member = relationship('UmsMember')
    product = relationship('PmsProduct')
示例#13
0
class PmsSkuStock(Base):
    __tablename__ = 'pms_sku_stock'
    __table_args__ = {'comment': 'sku的库存'}

    id = Column(BIGINT(20), primary_key=True, nullable=False)
    product_id = Column(ForeignKey('pms_product.id',
                                   ondelete='RESTRICT',
                                   onupdate='RESTRICT'),
                        index=True)
    sku_code = Column(VARCHAR(64),
                      primary_key=True,
                      nullable=False,
                      comment='sku编码')
    price = Column(DECIMAL(10, 2))
    stock = Column(INTEGER(11), server_default=text("'0'"), comment='库存')
    low_stock = Column(INTEGER(11), comment='预警库存')
    pic = Column(VARCHAR(255), comment='展示图片')
    sale = Column(INTEGER(11), comment='销量')
    sp_data = Column(VARCHAR(500), comment='商品销售属性,json格式')

    product = relationship('PmsProduct')
示例#14
0
class FailedNodeJob(Base):
    __tablename__ = 'failed_node_jobs'
    __table_args__ = {'comment': '失败任务'}

    id = Column(BIGINT(20), primary_key=True)
    create_ip = Column(String(128, 'utf8mb4_unicode_ci'), server_default=text("''"), comment='创建任务ip')
    destnation_ip = Column(String(128, 'utf8mb4_unicode_ci'), server_default=text("''"), comment='需要执行任务服务器域名地址')
    server = Column(String(128, 'utf8mb4_unicode_ci'), server_default=text("''"), comment='请求服务器域名地址')
    json = Column(String(1000), nullable=False)
    count = Column(INTEGER(11), nullable=False, server_default=text("'0'"), comment='job执行次数')
    failed_at = Column(TIMESTAMP, nullable=False, server_default=text("CURRENT_TIMESTAMP"))
    status = Column(TINYINT(4), nullable=False, server_default=text("'1'"), comment='状态:0-删除、1-待执行')
    def __init__(self, create_ip=None, destnation_ip=None, server=None, json=None):
        self.server = server
        self.create_ip = create_ip
        self.destnation_ip = destnation_ip
        self.server = server
        self.json = json
        self.count = 0
        self.failed_at = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())
        self.status = 1
class Users(db.Model):
    __tablename__ = "Registered_users_db"
    name = db.Column(db.String, nullable=False)
    email = db.Column(db.String, primary_key=True)
    password = db.Column(db.String, nullable=False)
    knowmsit = db.Column(db.String, nullable=False)
    contact = db.Column(BIGINT(unsigned=True), nullable=False)
    education = db.Column(db.String, nullable=False)
    timestamp = db.Column(db.DateTime(), nullable=False)
    active = db.Column(db.Boolean)

    def __init__(self, name, email, password, knowmsit, timestamp, active,
                 contact, education):
        self.name = name
        self.email = email
        self.password = password
        self.knowmsit = knowmsit
        self.contact = contact
        self.education = education
        self.timestamp = timestamp
        self.active = active
示例#16
0
class Vehicles(db.Model):
	id = db.Column(BIGINT(20, unsigned=True), primary_key=True)
	make = db.Column(VARCHAR(64), nullable=False, server_default='unknown')
	model = db.Column(VARCHAR(128), nullable=False)
	release_year = db.Column(INTEGER(display_width=4, unsigned=True, zerofill=True), nullable=False, server_default=text('1'))
	registration = db.Column(VARCHAR(16), nullable=False)
	fuel = db.Column(VARCHAR(8), nullable=False, server_default='unknown')
	tank_size = db.Column(DECIMAL(precision=4, scale=1, unsigned=True))
	initials =  db.Column(VARCHAR(4), nullable=False, server_default='xxx')
	created = db.Column(DATETIME, nullable=False, server_default=text('CURRENT_TIMESTAMP'))
	updated = db.Column(DATETIME, server_default=text('NULL ON UPDATE CURRENT_TIMESTAMP'))
	
	# Constructor
	def __init__(self, make, model, release_year, registration, fuel, tank_size, initials):
		self.make = make
		self.model = model
		self.release_year = release_year
		self.registration = registration
		self.fuel = fuel
		self.tank_size = tank_size
		self.initials = initials
示例#17
0
class PrimaryKeyBase(PrepareMixin, RecordMixin):  # noqa
    """Subclass this and include your declarative_base mixin"""

    __tablename__ = "primary_keys"

    # pyre-fixme[8]: Attribute has type `str`; used as `Column[str]`.
    table_name: str = Column(
        String(length=100),
        doc="Name of the table that this row stores the next available primary key for",
        nullable=False,
        primary_key=True,
    )

    # pyre-fixme[8]: Attribute has type `int`; used as
    #  `Column[Variable[sqlalchemy.sql.type_api._U]]`.
    current_id: int = Column(
        BIGINT(unsigned=True).with_variant(BIGINT, "sqlite"),
        doc="The current/latest id used in the table.",
        nullable=False,
        primary_key=False,
    )
示例#18
0
class SmsVerifyCode(Base):
    __tablename__ = 'sms_verify_code'

    id = Column(BIGINT(20), primary_key=True, comment='主键')
    mobile = Column(DECIMAL(11, 0))
    code = Column(String(255))
    active = Column(TINYINT(1),
                    nullable=False,
                    server_default=text("'1'"),
                    comment='对应该条记录是否可用,1可用,0不可用')
    version = Column(INTEGER(20),
                     nullable=False,
                     server_default=text("'0'"),
                     comment='对应乐观锁的版本号')
    gmt_create = Column(DateTime, nullable=False, comment='对应记录的创建时间')
    gmt_modified = Column(DateTime,
                          nullable=False,
                          server_default=text("CURRENT_TIMESTAMP"),
                          comment='对应记录的修改时间')
    create_by = Column(String(250), nullable=False, comment='对应添加记录的人')
    modified_by = Column(String(250), nullable=False, comment='对应最后一次修改记录的')
示例#19
0
class StreamChunk(Base):
    __tablename__ = "tb_stream_chunk"

    id = Column(Integer, primary_key=True)
    stream_id = Column(Integer, ForeignKey("tb_stream.id"), nullable=False)
    broadcast_id = Column(BIGINT(unsigned=True), nullable=False)
    video_url = Column(String(128), nullable=True)
    video_preview_image_url = Column(String(256), nullable=True)
    chunk_start = Column(DateTime, nullable=False)
    chunk_end = Column(DateTime, nullable=True)

    def __init__(self, stream, broadcast_id, created_at, **options):
        self.id = None
        self.stream_id = stream.id
        self.broadcast_id = broadcast_id
        self.video_url = None
        self.video_preview_image_url = None
        self.chunk_start = parse_twitch_datetime(created_at)
        self.chunk_end = None

        self.stream = stream
示例#20
0
class MessengerUser(db.Model):
    id = db.Column(BIGINT(unsigned=True), primary_key=True)
    sender_id = db.Column(db.String(255), nullable=False, unique=True)

    # TODO: needs to add other infos

    def __init__(self, sender_id):
        self.sender_id = sender_id

        user = MessengerUser.query.filter_by(sender_id=self.sender_id).first()

        if user:
            print("already added")
        else:
            db.session.add(self)
            db.session.commit()

    @classmethod
    def get_id(cls, sender_id):
        user = cls.query.filter_by(sender_id=sender_id).first()
        return user.id
示例#21
0
class SearchHistory(Base):
    __tablename__ = 'search_history'

    id = Column(BIGINT(20), primary_key=True, comment='主键')
    userid = Column(String(255))
    keyword = Column(String(500))
    active = Column(TINYINT(1),
                    nullable=False,
                    server_default=text("'1'"),
                    comment='对应该条记录是否可用,1可用,0不可用')
    version = Column(INTEGER(20),
                     nullable=False,
                     server_default=text("'0'"),
                     comment='对应乐观锁的版本号')
    gmt_create = Column(DateTime, nullable=False, comment='对应记录的创建时间')
    gmt_modified = Column(DateTime,
                          nullable=False,
                          server_default=text("CURRENT_TIMESTAMP"),
                          comment='对应记录的修改时间')
    create_by = Column(String(250), nullable=False, comment='对应添加记录的人')
    modified_by = Column(String(250), nullable=False, comment='对应最后一次修改记录的')
示例#22
0
class RequestLog(db.Model):
    __tablename__ = 'request_log'

    STATUS_ON = 1
    STATUS_OFF = 0

    id = Column(BIGINT(20), primary_key=True, comment='主键')
    account_id = Column(INTEGER(10), nullable=False, index=True, server_default=text("'0'"), comment='账户ID')
    send_mail = Column(String(255), nullable=False, comment='接收方账号')
    create_at = Column(DateTime, nullable=False, comment='创建时间')
    status = Column(TINYINT(3), nullable=False, server_default=text("'0'"), comment='状态码')

    @staticmethod
    def push(account_id: int, send_mail: str):
        instance = RequestLog()
        instance.account_id = account_id
        instance.send_mail = send_mail
        instance.create_at = datetime.now()
        instance.status = RequestLog.STATUS_ON
        db.session.add(instance)
        db.session.commit()
示例#23
0
class Category(db.Model):
    id = db.Column(BIGINT(unsigned=True), primary_key=True)
    name = db.Column(db.String(30), unique=True, nullable=False)
    description = db.Column(db.String(120), unique=False, nullable=False)
    img_url = db.Column(db.String(256), unique=False, nullable=False)
    # TODO: need to find out what does lazy=dynamic means
    products = db.relationship('Product', backref='products', lazy='dynamic')
    # FIXME: products of each categories should added as db.relationship

    def __init__(self, name, description, img_url):
        self.name = name
        self.description = description
        self.img_url = img_url

    def commit(self):
        """saves the object in database"""
        db.session.add(self)
        db.session.commit()

    def __repr__(self):
        return '<Category {}>'.format(self.id, self.name, self.thumb_urls)
示例#24
0
文件: models.py 项目: ShinyPolar/bot
class Guild(Base):
    __tablename__ = 'guilds'

    id = Column(INT(unsigned=True), primary_key=True)
    guild = Column(BIGINT(unsigned=True), unique=True)

    prefix = Column(String(5), default='$', nullable=False)
    timezone = Column(String(32), default='UTC', nullable=False)

    name = Column(String(100))

    users = relationship('User',
                         secondary=guild_users,
                         primaryjoin=(guild_users.c.guild == id),
                         secondaryjoin='(guild_users.c.user == User.id)',
                         backref=backref('guilds', lazy='dynamic'),
                         lazy='dynamic')

    # populated later in file
    command_restrictions = None
    roles = None
示例#25
0
文件: db_orm.py 项目: helium876/mdl
class CompanyCategories(BASE):
    """Class defining the mdl_companycategories table of the database."""

    __tablename__ = 'mdl_companycategories'
    __table_args__ = ({'mysql_engine': 'InnoDB'})

    idx_companycategory = Column(BIGINT(unsigned=True),
                                 primary_key=True,
                                 autoincrement=True,
                                 nullable=False)

    companycategory_name = Column(VARBINARY(128), nullable=True, default=None)

    enabled = Column(INTEGER(unsigned=True), server_default='1')

    ts_modified = Column(
        DATETIME,
        server_default=text('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'),
    )

    ts_created = Column(DATETIME, server_default=text('CURRENT_TIMESTAMP'))
示例#26
0
文件: db_orm.py 项目: helium876/mdl
class AgentNames(BASE):
    """Class defining the mdl_agent table of the database."""

    __tablename__ = 'mdl_agentnames'
    __table_args__ = {'mysql_engine': 'InnoDB'}

    idx_agentname = Column(BIGINT(unsigned=True),
                           primary_key=True,
                           autoincrement=True,
                           nullable=False)

    agent_name = Column(VARBINARY(512), nullable=True, default=None)

    enabled = Column(INTEGER(unsigned=True), server_default='1')

    ts_modified = Column(
        DATETIME,
        server_default=text('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'),
    )

    ts_created = Column(DATETIME, server_default=text('CURRENT_TIMESTAMP'))
示例#27
0
class Advertising(Base):
    __tablename__ = 'advertising'

    id = Column(BIGINT(20), primary_key=True)
    title = Column(String(80), nullable=False, server_default=text("''"), comment='标题')
    description = Column(String(255), server_default=text("''"), comment='描述')
    start_at = Column(BIGINT(13), nullable=False, server_default=text("'0'"), comment='投放开始Unix时间戳毫秒单位')
    end_at = Column(BIGINT(13), nullable=False, server_default=text("'0'"), comment='投放结束Unix时间戳毫秒单位0 为无限')
    type = Column(TINYINT(1), nullable=False, server_default=text("'1'"), comment='广告类型 1 内部网页 2外部网页')
    client = Column(String(200), nullable=False, server_default=text("''"), comment='客户端:web wechat android ios 同时支持多个的话,用半角逗号分隔 ')
    img = Column(String(255), server_default=text("''"), comment='图片链接')
    link = Column(String(255), nullable=False, server_default=text("''"), comment='跳转地址链接')
    sort = Column(BIGINT(20), nullable=False, server_default=text("'20'"), comment='排序 降序排序,大的值在前面')
    category_id = Column(BIGINT(20), nullable=False, comment='广告分类 投放位置')
    status = Column(TINYINT(1), server_default=text("'1'"), comment='状态:( 0 禁用;1 启用, 默认1 删除 -1)')
    created_at = Column(BIGINT(13), nullable=False, comment='创建记录Unix时间戳毫秒单位')
示例#28
0
class Reading(db.Model):
    __tablename__ = 'reading'

    reading_id = Column(BIGINT(20), primary_key=True)
    user_id = Column(ForeignKey('users.user_id'), nullable=False, index=True)
    notebook_id = Column(ForeignKey('notebooks.notebook_id'),
                         nullable=False,
                         index=True)

    notebook = relationship('Notebook')
    user = relationship('User')

    @classmethod
    def find(cls, user: int, notebook: id):
        return cls.query.filter_by(user_id=user, notebook_id=notebook).first()

    @classmethod
    def find_by_id(cls, id: int):
        return cls.query.filter_by(reading_id=id).first()

    @classmethod
    def find_user_list(cls, id: int, include_notebook_info: bool = False):
        if include_notebook_info:
            return cls.query.join(
                Notebook, Reading.notebook_id == Notebook.notebook_id).filter(
                    Reading.user_id == id).all()
        return cls.query.filter_by(user_id=id).all()

    @classmethod
    def exists(cls, user: int, notebook: int):
        return cls.query.filter_by(user_id=user,
                                   notebook_id=notebook).first() is not None

    def save_to_db(self):
        db.session.add(self)
        db.session.commit()

    def delete_from_db(self):
        db.session.delete(self)
        db.session.commit()
示例#29
0
class FqUser(Base):
    __tablename__ = 'fq_users'

    id = Column(BIGINT(20), primary_key=True)
    name = Column(String(20),
                  nullable=False,
                  server_default=text("''"),
                  comment='名字')
    user_wx = Column(String(100),
                     nullable=False,
                     server_default=text("''"),
                     comment='用户微信')
    user_type = Column(String(10),
                       nullable=False,
                       server_default=text("''"),
                       comment='用户付费类型')
    user_status = Column(String(10),
                         nullable=False,
                         server_default=text("''"),
                         comment='用户付费状态')
    user_url = Column(String(200),
                      nullable=False,
                      server_default=text("''"),
                      comment='用户短连接base64')
    user_price = Column(String(10),
                        nullable=False,
                        server_default=text("''"),
                        comment='用户价格')
    fq_text = Column(Text)
    yjl_user = Column(String(100))
    yjl_pwd = Column(String(100))
    create_time = Column(TIMESTAMP,
                         nullable=False,
                         server_default=text("CURRENT_TIMESTAMP"),
                         comment='创建时间')
    update_time = Column(
        TIMESTAMP,
        nullable=False,
        server_default=text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"),
        comment='更新时间')
示例#30
0
class User(Base):
    __tablename__ = 'user'

    id = Column(BIGINT(20), primary_key=True, comment='主键')
    level_id = Column(BIGINT(20),
                      nullable=False,
                      server_default=text("'0'"),
                      comment='会员等级ID')
    password = Column(String(128), nullable=False)
    username = Column(String(40), comment='登录名、昵称')
    mobile = Column(String(11))
    email = Column(String(80))
    experience = Column(BIGINT(20),
                        nullable=False,
                        server_default=text("'0'"),
                        comment='经验值')
    sex = Column(Enum('hide', 'male', 'female', 'other'),
                 nullable=False,
                 server_default=text("'hide'"),
                 comment='性别(男 male ,女 female 隐藏 hide)')
    avatar = Column(String(255),
                    nullable=False,
                    server_default=text("''"),
                    comment='头像')
    sign = Column(String(255), server_default=text("''"), comment='会员签名')
    login_count = Column(BIGINT(20),
                         nullable=False,
                         server_default=text("'0'"),
                         comment='登陆次数')
    last_login_ip = Column(String(40),
                           nullable=False,
                           server_default=text("''"),
                           comment='最后登陆IP')
    last_login_at = Column(BIGINT(13), comment='最后登录UTC时间')
    ref_user_id = Column(CHAR(32), comment='推荐人ID,空字符串表示为推荐人')
    status = Column(TINYINT(1),
                    nullable=False,
                    server_default=text("'1'"),
                    comment='状态:( 0 禁用;1 启用, 默认1)')
    deleted = Column(TINYINT(1),
                     nullable=False,
                     server_default=text("'0'"),
                     comment='已删除的 1 是 0 否 默认 0')
    created_at = Column(BIGINT(13), comment='创建记录UTC时间')
    reg_ip = Column(String(40), comment='注册IP')
    reg_client = Column(String(20),
                        comment='客户端:web wechat android ios mobile')