コード例 #1
0
class AccountDbo(EntityManager.get_base()):
    """
    The Account Database Object
    """
    __tablename__ = 'accounts'
    id = Column(Integer, primary_key=True)
    name = Column(String(50), unique=True)
    description = Column(String(250))
    transactions = relationship('TransactionDbo', backref='account')
    color = Column(String(50))
    notify = Column(Boolean())
    active = Column(Boolean())
    status = relationship('StatusDbo', backref='account')

    def __init__(self, id=None,  name=None, description=None, color=None, notify=None, active=None):
        """Constructor"""
        self.id = id
        self.name = name
        self.description = description
        self.color = color
        self.notify = notify
        self.active = active

    def __repr__(self):
        """String representation"""
        return '<AccountDbo %r, %r>' % (self.id, self.name)
コード例 #2
0
class SerializeModel(BaseModel):
    __tablename__ = 'test_table_2'
    id = Column(Integer, primary_key=True)
    title = Column(String(256))
    action = Column(String(256))

    _default_fields = ["id", "title", "action"]
コード例 #3
0
class BudgetDbo(EntityManager.get_base()):
    """
    The Budget Database Object
    """
    __tablename__ = 'budgets'
    id = Column(Integer, primary_key=True)
    name = Column(String(50))
    description = Column(String(250))
    period = Column(String(50))
    amount = Column(Numeric(precision=2))
    accounts = relationship('AccountDbo', secondary=budgets_accounts_table)
    labels = relationship('LabelDbo', secondary=budgets_labels_table)

    def __init__(self, id=None, name=None, description=None, period=None, amount=None, accounts=None, labels=None):
        """Constructor"""
        self.id = id
        self.name = name
        self.description = description
        self.period = period
        self.amount = amount
        self.accounts = [] if accounts is None else accounts
        self.labels = [] if labels is None else labels

    def __repr__(self):
        """String representation"""
        return '<BudgetDbo %r, %r>' % (self.id, self.name)
コード例 #4
0
class Message(Base):
    __tablename__ = 'messages'
    id = Column(Integer, primary_key=True, autoincrement=True)
    created = Column(DateTime, default=func.now())
    channel = Column(String(30), nullable=False, index=True)
    key = Column(String(20), nullable=False, index=True)
    message = Column(String(200), nullable=False)
コード例 #5
0
class MemeCorrectTest(training_base):
    __tablename__ = "meme_correct_test"

    id = Column(Integer, primary_key=True)
    name = Column(String(400), nullable=False)
    path = Column(String(400), nullable=False)
    name_idx = Column(Integer, nullable=True)
コード例 #6
0
class Template(training_base):
    __tablename__ = "templates"

    id = Column(Integer, primary_key=True)
    name = Column(String(400), nullable=False)
    page = Column(String(400), unique=True, nullable=False)
    blank_url = Column(String(400), nullable=False)
コード例 #7
0
class Image(db.Model):
    __tablename__ = 'images'
    id = Column(Integer, primary_key=True)
    name = Column(String(255), unique=True, nullable=False)
    image_path = Column(String(255), unique=True, nullable=False)
    created_at = Column(Date, default=datetime.datetime.now())
    updated_at = Column(Date, onupdate=datetime.datetime.now())

    def save(self, file):
        if file and Image.allowed_image(file.filename):
            filename = secure_filename(file.filename)
            try:
                path = os.path.join(current_app.config['IMAGES_UPLOAD_FOLDER'],
                                    filename)
                self.name = filename
                self.image_path = path
                db.session.add(self)

                file.save(path)
            except Exception as e:
                raise e

    @staticmethod
    def allowed_image(filename):
        return '.' in filename and \
            filename.rsplit('.', 1)[1] in current_app.config.get('IMAGE_ALLOWED_EXTENSIONS')
コード例 #8
0
class Account(Base):

    __tablename__ = 'account'

    id = Column(Integer, primary_key=True, autoincrement=True)
    auth_id = Column(String(40))
    username = Column(String(30))
コード例 #9
0
ファイル: schema.py プロジェクト: jazzPouls/pulse-data
class ReportTableDefinition(JusticeCountsBase):
    """The definition for what a table within a report describes."""

    __tablename__ = "report_table_definition"

    id = Column(Integer, autoincrement=True)

    system = Column(Enum(System))
    metric_type = Column(Enum(MetricType))
    measurement_type = Column(Enum(MeasurementType))

    # Any dimensions where the data in the table only accounts for a subset of values for that dimension. For instance,
    # a table for the population metric may only cover data for the prison population, not those on parole or
    # probation. In that case filters would include a filter on population type.
    filtered_dimensions = Column(ARRAY(String(255)))
    # The value for each dimension from the above array.
    filtered_dimension_values = Column(ARRAY(String(255)))
    # The dimensions that the metric is broken down by in the report table. Each cell in a table instance has a unique
    # combination of values for the aggregated dimensions. Dimensions are sorted deterministically within the array.
    aggregated_dimensions = Column(ARRAY(String(255)))

    __table_args__ = tuple(
        [
            PrimaryKeyConstraint(id),
            UniqueConstraint(
                metric_type,
                measurement_type,
                filtered_dimensions,
                filtered_dimension_values,
                aggregated_dimensions,
            ),
        ]
    )
コード例 #10
0
ファイル: schema.py プロジェクト: Leo-Ryu/pulse-data
class Report(JusticeCountsBase):
    """A document that is published by a source that contains data pertaining to the Justice Counts Framework.
    """
    __tablename__ = 'report'

    id = Column(Integer, autoincrement=True)

    # The source that this report is published by.
    source_id = Column(Integer, nullable=False)
    # This distinguishes between the many types of reports that a single source may produce, e.g. a Daily Status
    # Report or Monthly Fact Sheet, that contain different information and are potentially fetched and parsed using
    # different logic.
    type = Column(String(255), nullable=False)
    # Identifies a specific instance of a given report type. It should be constructed such that it is unique within a
    # given report type and source. The combination of report type and instance is used when ingesting a report to
    # determine whether this is an update to an existing report or a new report. For PDF reports, this may simply be
    # the title of the document after some validation has been performed. For webpages it may need to be dynamically
    # generated.
    instance = Column(String(255), nullable=False)

    # The date the report was published.
    publish_date = Column(Date, nullable=False)
    # The method used to acquire the data (e.g. scraped).
    acquisition_method = Column(Enum(AcquisitionMethod), nullable=False)
    # TODO(#4485): Add a list of projects (e.g. Justice Counts, Spark) for which this data was ingested.

    __table_args__ = tuple([
        PrimaryKeyConstraint(id),
        UniqueConstraint(source_id, type, instance),
        ForeignKeyConstraint([source_id], [Source.id])])

    source = relationship(Source)
コード例 #11
0
ファイル: __init__.py プロジェクト: mshafeequddin/Catalog
class User(Base):
    __tablename__ = 'user1'

    id = Column(Integer, primary_key=True)
    name = Column(String(250), nullable=False)
    email = Column(String(250), nullable=False)
    picture = Column(String(250))
コード例 #12
0
class Temp_table(declarative_base()):
    __tablename__ = 'test_table'
    __table_args__ = (PrimaryKeyConstraint('country', 'vehicle_id',
                                           'licence'), )
    country = Column(String(4))
    vehicle_id = Column(String(255))
    licence = Column(String(255))
コード例 #13
0
class ExtendedIntegerSequencedRecord(Base):
    __tablename__ = 'extended_integer_sequenced_items'

    id = Column(BigInteger().with_variant(Integer, "sqlite"), primary_key=True)

    # Sequence ID (e.g. an entity or aggregate ID).
    sequence_id = Column(UUIDType(), nullable=False)

    # Position (index) of item in sequence.
    position = Column(BigInteger(), nullable=False)

    # Topic of the item (e.g. path to domain event class).
    topic = Column(String(255), nullable=False)

    # State of the item (serialized dict, possibly encrypted).
    state = Column(Text())

    # Timestamp of the event.
    timestamp = Column(DECIMAL(24, 6, 6), nullable=False)
    # timestamp = Column(DECIMAL(27, 9, 9), nullable=False)

    # Type of the event (class name).
    event_type = Column(String(255))

    __table_args__ = (Index('integer_sequenced_items_index',
                            'sequence_id',
                            'position',
                            unique=True), )
コード例 #14
0
class KhZfTjCollectionModel(Base):
    @classmethod
    def keys(self):
        return [
            "qx",
            "ywmc",
            "ppmc",
            "yhmc",
            "sl",
            "khyc",
            "kdkhyc"  # , "rksj"#这里由于自己增加的时间与表格不对应。就不加上
        ]

    # 库名
    __dbname__ = "BossReport".lower()
    # 表名 yxbl_201706
    __tablename__ = "KhZfTj".lower()

    # 表结构
    id = Column(Integer(), primary_key=True)
    qx = Column(String(100), doc="区县")
    ywmc = Column(String(100), doc="业务名称")
    ppmc = Column(String(100), doc="品牌名称")
    yhmc = Column(String(100), doc="优惠名称")
    sl = Column(Integer(), doc="数量")
    khyc = Column(Integer(), doc="开户预存")
    kdkhyc = Column(Integer(), doc="宽带开户预存")
    rksj = Column(TIMESTAMP,
                  server_default=text("CURRENT_TIMESTAMP"),
                  doc="入库时间")
コード例 #15
0
class Billing(Base):
    __tablename__ = 'Billing'
    id = Column(Integer, primary_key=True)
    usage_date = Column(DATETIME)
    cost = Column(FLOAT)
    project_id = Column(String(16))
    resource_type = Column(String(128))
    account_id = Column(String(24))
    usage_value = Column(DECIMAL(25, 4))
    measurement_unit = Column(String(16))

    def __init__(self, usage_date, cost, project_id, resource_type, account_id,
                 usage_value, measurement_unit):
        self.usage_date = usage_date
        self.cost = cost
        self.project_id = project_id
        self.resource_type = resource_type
        self.account_id = account_id
        self.usage_value = usage_value
        self.measurement_unit = measurement_unit

    def __repr__(self):
        return '<Usage %r %r %r %r %r %r %r >' % (
            self.usage_date, self.cost, self.project_id, self.resource_type,
            self.account_id, self.usage_value, self.measurement_unit)
コード例 #16
0
def upgrade():

    # Creating 'budgets' table
    op.create_table('budgets', Column('id', Integer, primary_key=True),
                    Column('name', String(50), unique=True),
                    Column('description', String(250)),
                    Column('period', String(50)),
                    Column('amount', Numeric(precision=2)))

    # Creating 'budgets_accounts table'
    op.create_table(
        'budgets_accounts',
        Column('budget_id',
               Integer,
               ForeignKey('budgets.id'),
               primary_key=True),
        Column('account_id',
               Integer,
               ForeignKey('accounts.id'),
               primary_key=True))

    # Creating 'budgets_labels table'
    op.create_table(
        'budgets_labels',
        Column('budget_id',
               Integer,
               ForeignKey('budgets.id'),
               primary_key=True),
        Column('label_id', Integer, ForeignKey('labels.id'), primary_key=True))
    pass
コード例 #17
0
class DataBlockLog(BaseModel):
    id = Column(Integer, primary_key=True, autoincrement=True)
    snap_log_id = Column(Integer, ForeignKey(SnapLog.id), nullable=False)
    data_block_id = Column(
        String(128),
        ForeignKey(f"{SNAPFLOW_METADATA_TABLE_PREFIX}data_block_metadata.id"),
        nullable=False,
    )
    stream_name = Column(String(128), nullable=True)
    direction = Column(Enum(Direction, native_enum=False), nullable=False)
    processed_at = Column(DateTime, default=func.now(), nullable=False)
    invalidated = Column(Boolean, default=False)
    # Hints
    data_block: "DataBlockMetadata"
    snap_log: SnapLog

    def __repr__(self):
        return self._repr(
            id=self.id,
            snap_log=self.snap_log,
            data_block=self.data_block,
            direction=self.direction,
            processed_at=self.processed_at,
        )

    @classmethod
    def summary(cls, env: Environment) -> str:
        s = ""
        for dbl in env.md_api.execute(select(DataBlockLog)).scalars().all():
            s += f"{dbl.snap_log.node_key:50}"
            s += f"{str(dbl.data_block_id):23}"
            s += f"{str(dbl.data_block.record_count):6}"
            s += f"{dbl.direction.value:9}{str(dbl.data_block.updated_at):22}"
            s += f"{dbl.data_block.nominal_schema_key:20}{dbl.data_block.realized_schema_key:20}\n"
        return s
コード例 #18
0
class Alerts(Base):
    __tablename__ = 'alerts'

    id = Column('id', Integer, primary_key=True, autoincrement=True)
    timestamp = Column('t', Integer, nullable=False)
    source = Column('source', String(255), nullable=False)
    action = Column('action', String(255), nullable=True)
    risk = Column('riskValue', Float, nullable=True)
コード例 #19
0
ファイル: db.py プロジェクト: onemch/fastapidemo
class DB_User(Base):
    __tablename__ = 'user'

    id = Column(Integer, primary_key=True, index=True)
    username = Column(String(50))
    password = Column(String(50))
    sex = Column(Boolean, default=True)
    email = Column(String(50))
コード例 #20
0
 def validator_to_column(self,attr_obj):
     if type(attr_obj.validator.type) is tuple and any([ gtype in attr_obj.validator.type for gtype in (float,int)]):
         return Column(Numeric, default=attr_obj.default, nullable=True)
     if type(attr_obj.validator.type) is tuple and str in attr_obj.validator.type:
         return Column(String(DEFAULT_STRING_LENGTH),default=attr_obj.default, nullable=True)        
     if str is attr_obj.validator.type:
         return Column(String(DEFAULT_STRING_LENGTH),default=attr_obj.default, nullable=True)
     return Column(Numeric,default=attr_obj.default, nullable=True)   
コード例 #21
0
ファイル: models.py プロジェクト: AtteqCom/zsl_openapi
class User(DeclarativeBase):
    __tablename__ = 'user'
    __table_args__ = {'useexisting': True}

    id = Column(Integer, primary_key=True)
    name = Column(String(255), nullable=False)
    email = Column(String(255), nullable=False)
    created = Column(DateTime(), nullable=False)
コード例 #22
0
class Expression(PersistenObject):
    __tablename__ = 'fa_expression'
    expression = Column(String(255), nullable=False)
    periodType = Column(String(4), nullable=False)
    customConceptOID = Column(Integer, ForeignKey('fa_custom_concept.OID'))
    customConcept = relationship("CustomConcept",
                                 back_populates="expressionList")
    defaultOrder = Column(Integer, nullable=False)
    isCurrent = Column(Boolean, nullable=False)
コード例 #23
0
class PipeLog(BaseModel):
    id = Column(Integer, primary_key=True, autoincrement=True)
    graph_id = Column(
        String(128),
        ForeignKey(f"{SNAPFLOW_METADATA_TABLE_PREFIX}graph_metadata.hash"),
        nullable=False,
    )
    node_key = Column(String(128), nullable=False)
    node_start_state = Column(JSON, nullable=True)
    node_end_state = Column(JSON, nullable=True)
    pipe_key = Column(String(128), nullable=False)
    pipe_config = Column(JSON, nullable=True)
    runtime_url = Column(String(128), nullable=False)
    queued_at = Column(DateTime, nullable=True)
    started_at = Column(DateTime, nullable=True)
    completed_at = Column(DateTime, nullable=True)
    error = Column(JSON, nullable=True)
    data_block_logs: RelationshipProperty = relationship("DataBlockLog",
                                                         backref="pipe_log")
    graph: "GraphMetadata"

    def __repr__(self):
        return self._repr(
            id=self.id,
            graph_id=self.graph_id,
            node_key=self.node_key,
            pipe_key=self.pipe_key,
            runtime_url=self.runtime_url,
            started_at=self.started_at,
        )

    def output_data_blocks(self) -> Iterable[DataBlockMetadata]:
        return [
            dbl for dbl in self.data_block_logs
            if dbl.direction == Direction.OUTPUT
        ]

    def input_data_blocks(self) -> Iterable[DataBlockMetadata]:
        return [
            dbl for dbl in self.data_block_logs
            if dbl.direction == Direction.INPUT
        ]

    def set_error(self, e: Exception):
        tback = traceback.format_exc()
        # Traceback can be v large (like in max recursion), so we truncate to 5k chars
        self.error = {"error": str(e), "traceback": tback[:5000]}

    def persist_state(self, sess: Session) -> NodeState:
        state = (sess.query(NodeState).filter(
            NodeState.node_key == self.node_key).first())
        if state is None:
            state = NodeState(node_key=self.node_key)
            sess.add(state)
        state.state = self.node_end_state
        sess.flush([state])
        return state
コード例 #24
0
class User:
    __tablename__ = "user"

    id = Column(Integer, primary_key=True)
    name = Column(String(50))

    name3 = Column(String(50))

    addresses: List["Address"] = relationship("Address")
コード例 #25
0
class User(Base):
    __tablename__ = 'users'
    id = Column(Integer, primary_key=True)
    username = Column(String(50))
    password = Column(String(12))

    def __repr__(self):
        return "<User(name='%s', password='******')>" % (self.username,
                                                     self.password)
コード例 #26
0
ファイル: sources.py プロジェクト: logan-connolly/mychef
class Source(Base):
    """Source information for recipe provider"""

    __tablename__ = "sources"

    id = Column(Integer, primary_key=True)
    name = Column(String(255), nullable=False)
    url = Column(String(255), nullable=False, unique=True)
    ts = Column(DateTime, default=func.now())
コード例 #27
0
class GameInfo(Base):
    __tablename__ = 'game_info'
    __table_args__ = {"useexisting": True}
    id = Column(Integer, primary_key=True, autoincrement=True)
    # 指定name映射到name字段; name字段为字符串类形,
    icon = Column(Text)
    name = Column(String(32))
    info = Column(Text)
    md5 = Column(String(32))
コード例 #28
0
class Stats(Base):
    __tablename__ = 'stats'

    id = Column('id', Integer, primary_key=True, autoincrement=True)
    association = Column('association', String(255), nullable=False)
    parent = Column('parent', String(255), nullable=True)
    children = Column('children', String(255), nullable=True)
    value = Column('value', String(255), nullable=False)
    proba = Column('proba', Float, nullable=True)
コード例 #29
0
ファイル: __init__.py プロジェクト: F-Monkey/scrapy_notes
class Title(Base):
    __tablename__ = 'title'

    id = Column('id', INTEGER, primary_key=True)
    url = Column('url', String(250))
    title = Column('title', String(150))
    user_url = Column('user_url', String(250))

    def __repr__(self):
        return '%s' % self.title
コード例 #30
0
class SqlStoredEvent(Base):

    __tablename__ = 'stored_events'

    id = Column(Integer, Sequence('stored_event_id_seq'), primary_key=True)
    event_id = Column(String(255), index=True)
    timestamp_long = Column(BigInteger(), index=True)
    stored_entity_id = Column(String(255), index=True)
    event_topic = Column(String(255))
    event_attrs = Column(Text())