Пример #1
0
class FilesModel(BaseModel, Base):
    """附件表"""
    __tablename__ = 'files'
    file_md5 = Column(CHAR(32),
                      primary_key=True,
                      autoincrement=False,
                      doc='文件md5')
    form_code = Column(CHAR(32), nullable=False, index=True, doc='工单唯一编码')
    user_id = Column(Integer, nullable=False, doc='用户id')
    file_type = Column(VARCHAR(10), doc='文件类型(后缀)')
    file_name = Column(VARCHAR(255), doc='原始文件名')
    file_path = Column(VARCHAR(255), nullable=False, doc='文件储存路径')
    upload_time = Column(TIMESTAMP,
                         server_default=text('CURRENT_TIMESTAMP'),
                         doc='储存时间')

    @classmethod
    def insert(cls, file_md5: str, form_code: str, user_id: int,
               file_type: str, file_name: str, file_path: str):
        '''插入文件储信息
        :param cls:
        :param file_md5: 文件md5
        :param form_code: 工单唯一编码
        :param user_id: 用户id
        :param file_type: 文件类型(后缀)
        :param file_name: 原始文件名
        :param file_path: 文件储存路径
        '''
        return cls._insert(
            cls(file_md5=file_md5,
                form_code=form_code,
                user_id=user_id,
                file_type=file_type,
                file_name=file_name,
                file_path=file_path))
Пример #2
0
class WxArticle(Base):
    __table__ = Table(
        'wx_public_no', Base.metadata,
        Column('id', Integer, primary_key=True, autoincrement=True),
        Column('article_name', VARCHAR(256)), Column('article_content', TEXT),
        Column('article_link', VARCHAR(256)), Column('link_md5', VARCHAR(128)),
        Column('public_no', VARCHAR(128)),
        Column('public_no_link', VARCHAR(256)), Column('published_time', DATE))
Пример #3
0
class TypesModel(DeclarativeBase):

    __tablename__ = 'types'
    horo_id = Column(SmallInteger, primary_key=True, autoincrement=True)
    name = Column(VARCHAR(255))
    file = Column(VARCHAR(255), primary_key=True)

    def __init__(self, id, name, file):
        self.horo_id = id
        self.name = name
        self.file = file
Пример #4
0
class Style(Base):
    """ the styma table """
    __tablename__ = "styma"
    id = Column(Integer, name="styid", primary_key=True)
    alpha = Column(VARCHAR(2), nullable=False, name='alpha')
    digit = Column(Integer, name="digit", nullable=False)
    description = Column(VARCHAR(50), name="description", nullable=False)

    name = composite(StyElement, alpha, digit)

    UniqueConstraint(alpha, digit, name='idx_styno')
Пример #5
0
class News(Base):
    __table__ =Table('36ke_news',
                     Base.metadata,
                     Column('id', Integer, primary_key=True, autoincrement=True),
                     Column('ke_item', VARCHAR(64)),
                     Column('news_lable', VARCHAR(256)),
                     Column('news_name', VARCHAR(256)),
                     Column('news_content', TEXT),
                     Column('news_link', VARCHAR(256)),
                     Column('news_resource', VARCHAR(128)),
                     Column('news_date', DATE),
                     Column('published_time', DATE))
Пример #6
0
class Imagelib(Base):
    __tablename__ = 'imagelib'
    __table_args__ = {
        'mysql_charset': 'utf8'
    }
    id = Column(BIGINT, primary_key=True)
    type = Column(VARCHAR(20))
    image_name = Column(VARCHAR(260))
    image_url = Column(VARCHAR(260))
    position = Column(VARCHAR(100))
    #GPS pos : unused
    collection_id = Column(BIGINT, ForeignKey('collection.id'), nullable=False)
    create_time = Column(DATETIME, server_default=func.now())
Пример #7
0
 def test_string_types(
     self,
     metadata,
     connection,
 ):
     specs = [
         (String(125), VARCHAR(125)),
         (String(42).with_variant(VARCHAR2(42), "oracle"), VARCHAR(42)),
         (Unicode(125), VARCHAR(125)),
         (Unicode(42).with_variant(NVARCHAR2(42), "oracle"), NVARCHAR(42)),
         (CHAR(125), CHAR(125)),
         (NCHAR(42), NCHAR(42)),
     ]
     self._run_test(metadata, connection, specs, ["length"])
Пример #8
0
class FavoriteBox(Base):
    __tablename__ = 'favorite_box'
    __table_args__ = {
        'mysql_charset': 'utf8'
    }
    id = Column(INTEGER, primary_key=True)
    type = Column(VARCHAR(3), nullable=False)
    box_name = Column(VARCHAR(200), nullable=False)
    box_desc = Column(VARCHAR(200))
    focus_count = Column(INTEGER, default=0)
    box_count = Column(INTEGER, default=0)
    is_private = Column(BOOLEAN, default=False)
    create_by = Column(BIGINT, ForeignKey('user.id'))
    create_time = Column(DATETIME, server_default=func.now())
    favorites = relationship('Favorite', backref='myelement', lazy='dynamic')
Пример #9
0
class Topic(Base):
    __tablename__ = 'topic'
    __table_args__ = {
        'mysql_charset': 'utf8'
    }
    id = Column(INTEGER, primary_key=True)
    level_code = Column(VARCHAR(5), nullable=False)
    #leve_code define the topic's level on the topic tree.
    level_path = Column(VARCHAR(50))
    topic_name = Column(VARCHAR(50), unique=True)
    pic_url = Column(VARCHAR(300))
    topic_desc = Column(VARCHAR(500))
    focus_count = Column(INTEGER, default=0)
    create_by = Column(BIGINT, ForeignKey(User.id))
    create_time = Column(DATETIME, server_default=func.now())
Пример #10
0
class Strony(BaseModel):
    __tablename__   = 'strony'
    strona_id       = Column(BigInteger, primary_key=True)
    ksiazka_id      = Column(BigInteger, ForeignKey('ksiazki.ksiazka_id'))
    numer_strony    = Column(BigInteger)
    sciezka         = Column(VARCHAR(255))
    linie           = relationship('Ksiazki')
Пример #11
0
class User(Base):
    __tablename__ = 'user'

    id = Column('id', SmallInteger, primary_key=True, autoincrement=True)
    login_name = Column(VARCHAR(16), unique=True, nullable=False)
    first_name = Column(String(20), nullable=True)
    last_name = Column(VARCHAR(20))
    gender = Column(Enum(GenderEnum), nullable=False, default='M')
    age = Column(INTEGER)
    phone = Column(CHAR(11))
    password = Column(VARCHAR(512))

    def __repr__(self) -> str:
        # return super().__repr__()
        return "<{}: id={} login_name={} first_name={} last_name={} gender={} age={} phone={} password={}>".format(
            self.__class__.name, self.id, self.login_name, self.first_name,
            self.last_name, self.gender, self.age, self.phone, self.password)
class State(Base):
    """
    define a class state
    """
    __tablename__ = 'states'

    id = Column(Integer, primary_key=True)
    name = Column(VARCHAR(128), nullable=False)
Пример #13
0
class file_specs(db.Model):
    __tablename__ = 'file_specs'
    id = Column(Integer, primary_key=True, autoincrement=True)
    file_details_id = Column(Integer,
                             ForeignKey('file_details.id'),
                             nullable=False)
    column_name = Column(VARCHAR(30), nullable=True)
    column_type = Column(VARCHAR(30), nullable=True)
    min = Column(Float(), nullable=True)
    max = Column(Float(), nullable=True)
    avg = Column(Float(), nullable=True)
    median = Column(Float(), nullable=True)
    standard_deviation = Column(Float(), nullable=True)
    first_date = Column(DateTime(), nullable=True)
    last_date = Column(DateTime(), nullable=True)
    number_of_unique_values = Column(Integer(), nullable=True)
    number_of_null_values = Column(Integer(), nullable=True)
    number_of_nan_values = Column(Integer(), nullable=True)
Пример #14
0
class Litery(BaseModel):
    __tablename__   = 'litery'
    litera_id       = Column(BigInteger, primary_key=True)
    wyraz_id        = Column(BigInteger, ForeignKey('wyrazy.wyraz_id'))
    numer_litery    = Column(BigInteger)
    sciezka         = Column(VARCHAR(255))
    predykcja       = Column(CHAR(1))
    predykcja_slownik = Column(CHAR(1))
    litery          = relationship('Wyrazy', foreign_keys=wyraz_id)
Пример #15
0
class CollectPack(Base):
    __tablename__ = 'collect_pack'
    __table_args__ = {
        'mysql_charset': 'utf8'
    }
    id = Column(BIGINT, primary_key=True)
    type = Column(VARCHAR(3), nullable=False)
    pack_name = Column(VARCHAR(200), nullable=False)
    pack_desc = Column(VARCHAR(200))
    create_by = Column(BIGINT, ForeignKey('user.id'))
    topic_id = Column(VARCHAR(50))
    csn = Column(VARCHAR(200))
    #CopyRight Serial Number
    focus_count = Column(INTEGER, default=0)
    collect_count = Column(INTEGER, default=0)
    state = Column(INTEGER, default=1)
    create_time = Column(DATETIME, server_default=func.now())
    is_private = Column(BOOLEAN, default=False)
    collections = relationship('Collection', backref='folder', lazy='dynamic')
Пример #16
0
class Userfocus(Base):
    __tablename__ = 'userfocus'
    __table_args__ = {
        'mysql_charset': 'utf8'
    }
    id = Column(INTEGER, primary_key=True)
    user_id = Column(BIGINT, ForeignKey('user.id'))
    focus_type = Column(VARCHAR(3), nullable=False)
    #001 Collector ;002 Topic; 003 Collection etc.
    obj_id = Column(BIGINT, nullable=False)
    create_time = Column(DATETIME, server_default=func.now())
Пример #17
0
class Advice(Base):
    __tablename__ = "advice"
    __table_args__ = {
        'mysql_charset': 'utf8'
    }
    id = Column(INTEGER, primary_key=True)
    advice = Column(TEXT)
    contact = Column(VARCHAR(30))
    adviser_id = Column(BIGINT)
    #maybe None
    create_time = Column(DATETIME, server_default=func.now())
Пример #18
0
class Collection(Base):
    __tablename__ = 'collection'
    __table_args__ = {
        'mysql_charset': 'utf8'
    }
    id = Column(BIGINT, primary_key=True)
    type = Column(VARCHAR(2), nullable=False)
    title = Column(VARCHAR(100), nullable=False)
    cover = Column(VARCHAR(300))
    content = Column(TEXT)
    abstract = Column(VARCHAR(150))
    pack_id = Column(BIGINT, ForeignKey('collect_pack.id'))
    cisn = Column(VARCHAR(200))
    #CopyRight Identify Serial Number(cisn)
    create_by = Column(BIGINT, ForeignKey('user.id'))
    vote_count = Column(INTEGER, default=0)
    bro_count = Column(INTEGER, default=0)
    share_count = Column(INTEGER, default=0)
    visit_count = Column(INTEGER, default=0)
    focus_count = Column(INTEGER, default=0)
    comment_count = Column(INTEGER, default=0)
    state = Column(INTEGER, default=1)
    #1 valid 0 invalid
    create_time = Column(DATETIME, server_default=func.now())
    last_modify = Column(DATETIME, server_default=func.now())
    reserved = Column(VARCHAR(100))
    images = relationship('Imagelib', backref='relevance', lazy='dynamic')
    favorites = relationship('Favorite', backref='son', lazy='dynamic')
    comments = relationship('Comment', backref='target', lazy='dynamic')
Пример #19
0
class JO(Base):
    """ b_cust_bill table """
    __tablename__ = "b_cust_bill"
    id = Column(Integer, name="jsid", primary_key=True)
    alpha = Column(VARCHAR(2), nullable=False, name='cstbldid_alpha')
    digit = Column(Integer, name="cstbldid_digit", nullable=False)
    description = Column(VARCHAR(50), name="description", nullable=False)
    qty = Column(Float, name='quantity')
    '''
    _styid = Column(Integer, ForeignKey("styma.id"), name="styid")
    _cstid = Column(Integer, ForeignKey("customer.id"), name="cstid")
    
    customer = relationship('Customer', lazy = 'joined')
    customer = relation("Customer",backref="cstinfo")
    style = relation('Style', backref='style')    
    '''
    styid = Column(Integer, ForeignKey('styma.id'))
    cstid = Column(Integer, ForeignKey('customer.id'))

    name = composite(JOElement, alpha, digit)

    UniqueConstraint(alpha, digit, name='idx_jono')
Пример #20
0
class UserAction(Base):
    __tablename__ = "user_action"
    __table_args__ = {
        'mysql_charset': 'utf8'
    }
    id = Column(BIGINT, primary_key=True)
    action_type = Column(VARCHAR(4))
    #@see detail up
    uid = Column(BIGINT, ForeignKey('user.id'))
    # the user who produce this action
    obj_id = Column(BIGINT)
    # the object of action
    create_time = Column(DATETIME, server_default=func.now())
Пример #21
0
class NewsContent(Base):
    __table__ = Table(
        'news_content', Base.metadata,
        Column('id', Integer, primary_key=True, autoincrement=True),
        Column('WEBSITE_ID', Integer), Column('CRAWL_URL', VARCHAR(100)),
        Column('NEWS_NAME', VARCHAR(100)), Column('NEWS_URL', VARCHAR(100)),
        Column('NEWS_IMAGE', VARCHAR(100)), Column('NEWS_DESC', TEXT),
        Column('KEYWORDS', VARCHAR(100)), Column('PUBLISH_TIME', DATE),
        Column('NEWS_RESOURCE', VARCHAR(50)), Column('NEWS_AUTHOR',
                                                     VARCHAR(50)),
        Column('COMMENT_NUM', Integer), Column('READ_NUM', Integer))
Пример #22
0
class Message(Base):
    __tablename__ = "message"
    __table_args__ = {
        'mysql_charset': 'utf8'
    }
    id = Column(BIGINT, primary_key=True)
    type = Column(VARCHAR(3))
    content = Column(TEXT)
    is_read = Column(BOOLEAN, default=False)
    sender_id = Column(BIGINT, ForeignKey('user.id'))
    receiver_id = Column(BIGINT, ForeignKey('user.id'))
    accepted = Column(BOOLEAN, default=False)
    accept_time = Column(DATETIME)
    create_time = Column(DATETIME, server_default=func.now())
    msg_sender = relationship('User', foreign_keys=[sender_id])
    msg_receiver = relationship('User', foreign_keys=[receiver_id])
Пример #23
0
class jianshu_blog(Base):
    __table__ = Table(
        'jianshu_blog', Base.metadata,
        Column('id', Integer, primary_key=True, autoincrement=True),
        Column('main_topic', VARCHAR(64)), Column('topic_link', VARCHAR(256)),
        Column('blog_name', VARCHAR(256)), Column('blog_content', TEXT),
        Column('blog_link', VARCHAR(256)), Column('published_time', DATE),
        Column('blog_author', VARCHAR(128)), Column('author_link',
                                                    VARCHAR(256)),
        Column('read_num', Integer), Column('comment_num', Integer),
        Column('like_num', Integer), Column('support_num', Integer))
Пример #24
0
class Comment(Base):
    __tablename__ = "comment"
    __table_args__ = {
        'mysql_charset': 'utf8'
    }
    id = Column(BIGINT, primary_key=True)
    collection_id = Column(BIGINT, ForeignKey('collection.id'))
    receiver_id = Column(BIGINT, ForeignKey('user.id'))
    type = Column(VARCHAR(2))
    #10 common #20 reply
    content = Column(TEXT, nullable=False)
    report_count = Column(INTEGER, default=0)
    vote_count = Column(INTEGER, default=0)
    create_by = Column(BIGINT, ForeignKey('user.id'))
    create_time = Column(DATETIME, server_default=func.now())
    comment_sender = relationship('User', foreign_keys=[create_by])
    comment_receiver = relationship('User', foreign_keys=[receiver_id])
Пример #25
0
class GroupsModel(BaseModel, Base):
    """分组表"""
    __tablename__ = 'groups'
    group_id = Column(BigInteger,
                      primary_key=True,
                      autoincrement=True,
                      doc='分组ID')
    group_name = Column(VARCHAR(255), unique=True, doc='分组名称')

    @classmethod
    def insert(cls, group_name: str) -> int:
        '''插入分组
        :param cls:
        :param group_name: 分组名
        :return: ``int`` 0(fail) 1(success)
        '''
        return cls._insert(cls(group_name=group_name))
Пример #26
0
class FormsModel(BaseModel, Base):
    """工单表"""
    __tablename__ = 'forms'
    form_id = Column(BigInteger,
                     primary_key=True,
                     autoincrement=True,
                     doc='索引id')
    form_number = Column(VARCHAR(255), doc='介绍信编号')
    form_code = Column(CHAR(32), doc='工单唯一编码ID')
    user_id = Column(Integer, doc='用户id')
    group_id = Column(Integer, doc='区县ID')
    form_urgent = Column(Integer, doc='紧急1或普通0')
    form_state = Column(CHAR(3), doc='工单状态(审批中)')
    form_detail = Column(TEXT, doc='工单说明')
    form_phones = Column(TEXT, doc='查询的手机号码')
    form_result = Column(TEXT, doc='处理结果')
    form_time = Column(DATETIME, doc='工单时间')
Пример #27
0
class WeeklyModel(DeclarativeBase):

    __tablename__ = 'weekly'
    id = Column(Integer, primary_key=True, autoincrement=True)
    horo_id = Column(SmallInteger)
    horo_date = Column(VARCHAR(50), default='')
    aries = Column(Text, default='')
    taurus = Column(Text, default='')
    gemini = Column(Text, default='')
    cancer = Column(Text, default='')
    leo = Column(Text, default='')
    virgo = Column(Text, default='')
    libra = Column(Text, default='')
    scorpio = Column(Text, default='')
    sagittarius = Column(Text, default='')
    capricorn = Column(Text, default='')
    aquarius = Column(Text, default='')
    pisces = Column(Text, default='')

    def __init__(self, id):
        self.horo_id = id
    def test_get_columns(self, use_sql_fallback, engine_name):
        with self.engine_map[engine_name].begin() as c:
            dialect = Inspector(c).dialect
            columns = dialect.get_columns(connection=c,
                                          schema=self.schema,
                                          table_name="t",
                                          use_sql_fallback=use_sql_fallback)
            expected = [
                {
                    'default': None,
                    'is_distribution_key': False,
                    'name': 'pid1',
                    'nullable': False,
                    'type': INTEGER()
                },
                {
                    'default': None,
                    'is_distribution_key': False,
                    'name': 'pid2',
                    'nullable': False,
                    'type': INTEGER()
                },
                {
                    'default': None,
                    'is_distribution_key': False,
                    'name': 'name',
                    'nullable': True,
                    'type': VARCHAR(length=20)
                },
                {
                    'default': None,
                    'is_distribution_key': False,
                    'name': 'age',
                    'nullable': True,
                    'type': INTEGER()
                },
            ]

            assert self.make_columns_comparable(
                expected) == self.make_columns_comparable(columns)
Пример #29
0
class LogsModel(BaseModel, Base):
    """日志表"""
    __tablename__ = 'logs'
    log_id = Column(BigInteger,
                    primary_key=True,
                    autoincrement=True,
                    doc='索引id')
    user_id = Column(BigInteger, doc='用户ID')
    log_func = Column(VARCHAR(255), doc='操作名称')
    log_time = Column(TIMESTAMP,
                      server_default=text('CURRENT_TIMESTAMP'),
                      doc='操作时间')

    @classmethod
    def insert(cls, user_id: int, log_func: str) -> int:
        '''插入操作日志
        :param cls:
        :param user_id: 用户的ID
        :param log_func: 操作名称
        :return: ``int`` 0(fail) 1(success)
        '''
        return cls._insert(cls(user_id=user_id, log_func=log_func))
Пример #30
0
class ServerConfig(Base):
    __tablename__ = "server_config"
    __table_args__ = {
        'mysql_charset': 'utf8'
    }
    id = Column(INTEGER, primary_key=True)
    cfg_type = Column(VARCHAR(30), nullable=False)
    #configuration type
    cfg_key = Column(VARCHAR(30), unique=True)
    #configuration key unique
    cfg_name = Column(VARCHAR(50))
    #configuration name
    field_a = Column(VARCHAR(260))
    #value 1
    field_b = Column(VARCHAR(260))
    #value 2
    field_c = Column(VARCHAR(260))
    #value 3
    comment = Column(VARCHAR(100))
    create_time = Column(DATETIME, server_default=func.now())