當前位置: 首頁>>代碼示例>>Python>>正文


Python mysql.DATETIME屬性代碼示例

本文整理匯總了Python中sqlalchemy.dialects.mysql.DATETIME屬性的典型用法代碼示例。如果您正苦於以下問題:Python mysql.DATETIME屬性的具體用法?Python mysql.DATETIME怎麽用?Python mysql.DATETIME使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在sqlalchemy.dialects.mysql的用法示例。


在下文中一共展示了mysql.DATETIME屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: actual_complex_data

# 需要導入模塊: from sqlalchemy.dialects import mysql [as 別名]
# 或者: from sqlalchemy.dialects.mysql import DATETIME [as 別名]
def actual_complex_data(self, complex_table_schema):
        res = {'id': 1}
        for indx, complex_column_schema in enumerate(complex_table_schema):
            if isinstance(complex_column_schema.sqla_obj, mysql.DATE):
                data = complex_column_schema.data.strftime('%Y-%m-%d')
            elif isinstance(complex_column_schema.sqla_obj, mysql.DATETIME):
                data = complex_column_schema.data.strftime('%Y-%m-%d %H:%M:%S.%f')
            elif isinstance(complex_column_schema.sqla_obj, mysql.TIMESTAMP):
                data = complex_column_schema.data.strftime('%Y-%m-%d %H:%M:%S.%f')
            elif isinstance(complex_column_schema.sqla_obj, mysql.TIME):
                time = datetime.time(
                    complex_column_schema.data.seconds / 3600,
                    (complex_column_schema.data.seconds / 60) % 60,
                    complex_column_schema.data.seconds % 60,
                    complex_column_schema.data.microseconds
                )
                data = time.strftime('%H:%M:%S.%f')
            else:
                data = complex_column_schema.data
            res.update({self._build_sql_column_name(indx): data})
        return res 
開發者ID:Yelp,項目名稱:mysql_streamer,代碼行數:23,代碼來源:end_to_end_test.py

示例2: expected_complex_data

# 需要導入模塊: from sqlalchemy.dialects import mysql [as 別名]
# 或者: from sqlalchemy.dialects.mysql import DATETIME [as 別名]
def expected_complex_data(self, actual_complex_data, complex_table_schema):
        expected_complex_data_dict = {'id': 1}
        for indx, complex_column_schema in enumerate(complex_table_schema):
            column_name = self._build_sql_column_name(indx)
            if isinstance(complex_column_schema.sqla_obj, mysql.SET):
                expected_complex_data_dict[column_name] = \
                    sorted(actual_complex_data[column_name])
            elif isinstance(complex_column_schema.sqla_obj, mysql.DATETIME):
                date_time_obj = \
                    complex_column_schema.data.isoformat()
                expected_complex_data_dict[column_name] = date_time_obj
            elif isinstance(complex_column_schema.sqla_obj, mysql.TIMESTAMP):
                date_time_obj = \
                    complex_column_schema.data.replace(tzinfo=pytz.utc)
                expected_complex_data_dict[column_name] = date_time_obj
            elif isinstance(complex_column_schema.sqla_obj, mysql.TIME):
                number_of_micros = transform_timedelta_to_number_of_microseconds(
                    complex_column_schema.data
                )
                expected_complex_data_dict[column_name] = number_of_micros
            else:
                expected_complex_data_dict[column_name] = \
                    complex_column_schema.data
        return expected_complex_data_dict 
開發者ID:Yelp,項目名稱:mysql_streamer,代碼行數:26,代碼來源:end_to_end_test.py

示例3: load_dialect_impl

# 需要導入模塊: from sqlalchemy.dialects import mysql [as 別名]
# 或者: from sqlalchemy.dialects.mysql import DATETIME [as 別名]
def load_dialect_impl(self, dialect):
        if dialect.name == 'mysql':
            return dialect.type_descriptor(mysql.DATETIME(fsp=6))
        return self.impl 
開發者ID:gnocchixyz,項目名稱:gnocchi,代碼行數:6,代碼來源:sqlalchemy_types.py

示例4: upgrade

# 需要導入模塊: from sqlalchemy.dialects import mysql [as 別名]
# 或者: from sqlalchemy.dialects.mysql import DATETIME [as 別名]
def upgrade():
    op.create_table('enforcements',
      sa.Column('enforcement_id', mysql.INTEGER(unsigned=True), nullable=False, autoincrement=True),
      sa.Column('account_id', mysql.INTEGER(unsigned=True)),
      sa.Column('resource_id', sa.String(length=256), nullable=False),
      sa.Column('action', sa.String(length=64), nullable=False),
      sa.Column('timestamp', mysql.DATETIME(timezone=False), default=func.now()),
      sa.Column('metrics', mysql.JSON()),
      sa.PrimaryKeyConstraint('enforcement_id')) 
開發者ID:RiotGames,項目名稱:cloud-inquisitor,代碼行數:11,代碼來源:3fca8951cd76_new_enforcements_table.py

示例5: upgrade

# 需要導入模塊: from sqlalchemy.dialects import mysql [as 別名]
# 或者: from sqlalchemy.dialects.mysql import DATETIME [as 別名]
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('enqueued_tasks',
    sa.Column('created_at', mysql.DATETIME(), nullable=False),
    sa.Column('updated_at', mysql.DATETIME(), nullable=False),
    sa.Column('id', mysql.INTEGER(display_width=11), nullable=False),
    sa.Column('task_namespace', mysql.VARCHAR(length=100), nullable=True),
    sa.Column('task_name', mysql.VARCHAR(length=255), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    )
    # ### end Alembic commands ### 
開發者ID:google,項目名稱:crmint,代碼行數:13,代碼來源:e34417c82307_new_model_to_track_.py

示例6: upgrade

# 需要導入模塊: from sqlalchemy.dialects import mysql [as 別名]
# 或者: from sqlalchemy.dialects.mysql import DATETIME [as 別名]
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('general_settings',
                    sa.Column('id', mysql.INTEGER(display_width=11), nullable=False),
                    sa.Column('name', mysql.VARCHAR(length=255), nullable=True),
                    sa.Column('value', sa.Text(), nullable=True),
                    sa.Column('created_at', mysql.DATETIME(), nullable=False),
                    sa.Column('updated_at', mysql.DATETIME(), nullable=False),
                    sa.PrimaryKeyConstraint('id'),
                    mysql_default_charset=u'utf8',
                    mysql_engine=u'InnoDB'
                    )
    # ### end Alembic commands ### 
開發者ID:google,項目名稱:crmint,代碼行數:15,代碼來源:60f68ec8a068_create_general_settings.py

示例7: upgrade

# 需要導入模塊: from sqlalchemy.dialects import mysql [as 別名]
# 或者: from sqlalchemy.dialects.mysql import DATETIME [as 別名]
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('schedules',
    sa.Column('created_at', mysql.DATETIME(), nullable=False),
    sa.Column('updated_at', mysql.DATETIME(), nullable=False),
    sa.Column('id', mysql.INTEGER(display_width=11), nullable=False),
    sa.Column('cron', mysql.VARCHAR(length=255), nullable=True),
    sa.Column('pipeline_id', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True),
    sa.ForeignKeyConstraint(['pipeline_id'], [u'pipelines.id'], name=u'schedules_ibfk_1'),
    sa.PrimaryKeyConstraint('id'),
    mysql_default_charset=u'utf8',
    mysql_engine=u'InnoDB'
    )
    # ### end Alembic commands ### 
開發者ID:google,項目名稱:crmint,代碼行數:16,代碼來源:95a62f05f603_create_schedules.py

示例8: MillisecondDatetime

# 需要導入模塊: from sqlalchemy.dialects import mysql [as 別名]
# 或者: from sqlalchemy.dialects.mysql import DATETIME [as 別名]
def MillisecondDatetime():
    """Return a datetime type with millisecond precision.

    Returns:
      A column type.
    """
    return sql.DateTime().with_variant(mysql.DATETIME(fsp=3), "mysql") 
開發者ID:ChrisCummins,項目名稱:clgen,代碼行數:9,代碼來源:sqlutil.py

示例9: downgrade

# 需要導入模塊: from sqlalchemy.dialects import mysql [as 別名]
# 或者: from sqlalchemy.dialects.mysql import DATETIME [as 別名]
def downgrade():
    op.add_column('spoolmessage', sa.Column(u'replyto_thread_id',
                                            mysql.INTEGER(display_width=11),
                                            nullable=True))
    op.add_column('spoolmessage', sa.Column(u'draft_copied_from',
                                            mysql.INTEGER(display_width=11),
                                            nullable=True))
    op.drop_column('spoolmessage', 'is_reply')
    op.create_table(
        u'draftthread',
        sa.Column(u'created_at', mysql.DATETIME(), nullable=False),
        sa.Column(u'updated_at', mysql.DATETIME(), nullable=False),
        sa.Column(u'deleted_at', mysql.DATETIME(), nullable=True),
        sa.Column(u'public_id', sa.BINARY(length=16), nullable=False),
        sa.Column(u'id', mysql.INTEGER(display_width=11), nullable=False),
        sa.Column(u'master_public_id', sa.BINARY(length=16), nullable=False),
        sa.Column(u'thread_id', mysql.INTEGER(display_width=11),
                  autoincrement=False, nullable=False),
        sa.Column(u'message_id', mysql.INTEGER(display_width=11),
                  autoincrement=False, nullable=False),
        sa.ForeignKeyConstraint(['message_id'], [u'message.id'],
                                name=u'draftthread_ibfk_2'),
        sa.ForeignKeyConstraint(['thread_id'], [u'thread.id'],
                                name=u'draftthread_ibfk_1'),
        sa.PrimaryKeyConstraint(u'id'),
        mysql_default_charset=u'utf8mb4',
        mysql_engine=u'InnoDB'
    ) 
開發者ID:nylas,項目名稱:sync-engine,代碼行數:30,代碼來源:044_update_drafts_schema.py

示例10: upgrade

# 需要導入模塊: from sqlalchemy.dialects import mysql [as 別名]
# 或者: from sqlalchemy.dialects.mysql import DATETIME [as 別名]
def upgrade():
    conn = op.get_bind()
    conn.execute(text("ALTER TABLE accounttransaction "
                      " MODIFY COLUMN updated_at DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00'"))
    conn.execute(text("ALTER TABLE messagecategory"
                      " MODIFY COLUMN updated_at DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00'"))
    conn.execute(text("ALTER TABLE messagecontactassociation"
                      " MODIFY COLUMN updated_at DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00'"))
    conn.execute(text("ALTER TABLE transaction"
                      " MODIFY COLUMN updated_at DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00'"))

    conn.execute(text("ALTER TABLE accounttransaction DROP updated_at,"
                      "DROP deleted_at"))
    conn.execute(text("ALTER TABLE messagecategory DROP updated_at,"
                      "DROP deleted_at"))
    conn.execute(text("ALTER TABLE messagecontactassociation DROP updated_at,"
                      "DROP deleted_at"))
    conn.execute(text("ALTER TABLE thread DROP deleted_at, DROP INDEX"
                      " ix_thread_namespace_id_recentdate_deleted_at"))
    conn.execute(text("ALTER TABLE transaction DROP deleted_at,"
                      "DROP updated_at"))
    if conn.engine.has_table('easdevice'):
        # Run EAS specific migrations
        conn.execute(text("ALTER TABLE easdevice"
                          " MODIFY COLUMN updated_at DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00'"))
        conn.execute(text("ALTER TABLE easdevice DROP deleted_at,"
                          "DROP updated_at")) 
開發者ID:nylas,項目名稱:sync-engine,代碼行數:29,代碼來源:223_time_mixins_fix.py

示例11: upgrade

# 需要導入模塊: from sqlalchemy.dialects import mysql [as 別名]
# 或者: from sqlalchemy.dialects.mysql import DATETIME [as 別名]
def upgrade():
    op.add_column('message',
                  sa.Column('is_read', sa.Boolean(),
                            server_default=sa.sql.expression.false(),
                            nullable=False))

    op.alter_column('usertagitem', 'created_at',
                    existing_type=mysql.DATETIME(), nullable=False)
    op.alter_column('usertagitem', 'updated_at',
                    existing_type=mysql.DATETIME(), nullable=False)

    from inbox.models.session import session_scope
    from inbox.ignition import main_engine
    engine = main_engine(pool_size=1, max_overflow=0)
    Base = declarative_base()
    Base.metadata.reflect(engine)

    class Message(Base):
        __table__ = Base.metadata.tables['message']

    class ImapUid(Base):
        __table__ = Base.metadata.tables['imapuid']
        message = relationship('Message',
                               backref=backref('imapuids',
                                               primaryjoin='and_('
                                               'Message.id == ImapUid.message_id, '
                                               'ImapUid.deleted_at == None)'),
                               primaryjoin='and_('
                               'ImapUid.message_id == Message.id,'
                               'Message.deleted_at == None)')

    with session_scope(versioned=False) as db_session:
        for uid in db_session.query(ImapUid).yield_per(500):
            if uid.is_seen:
                uid.message.is_read = True

        db_session.commit() 
開發者ID:nylas,項目名稱:sync-engine,代碼行數:39,代碼來源:030_add_is_read_attribute_to_messages.py

示例12: downgrade

# 需要導入模塊: from sqlalchemy.dialects import mysql [as 別名]
# 或者: from sqlalchemy.dialects.mysql import DATETIME [as 別名]
def downgrade():
    op.create_table('searchindexcursor',
                    sa.Column('created_at', mysql.DATETIME(), nullable=False),
                    sa.Column('updated_at', mysql.DATETIME(), nullable=False),
                    sa.Column('deleted_at', mysql.DATETIME(), nullable=True),
                    sa.Column('id', mysql.INTEGER(display_width=11), nullable=False),
                    sa.Column('transaction_id', mysql.INTEGER(display_width=11), autoincrement=False, nullable=True),
                    sa.ForeignKeyConstraint(['transaction_id'], [u'transaction.id'], name=u'searchindexcursor_ibfk_1'),
                    sa.PrimaryKeyConstraint('id'),
                    mysql_default_charset=u'utf8mb4',
                    mysql_engine=u'InnoDB'
                    )
    op.drop_table('contactsearchindexcursor') 
開發者ID:nylas,項目名稱:sync-engine,代碼行數:15,代碼來源:207_add_contact_search_index_service_cursor_.py

示例13: upgrade

# 需要導入模塊: from sqlalchemy.dialects import mysql [as 別名]
# 或者: from sqlalchemy.dialects.mysql import DATETIME [as 別名]
def upgrade():   # noqa: D103
    if context.config.get_main_option('sqlalchemy.url').startswith('mysql'):
        op.alter_column(table_name='dag', column_name='last_scheduler_run',
                        type_=mysql.DATETIME(fsp=6))
        op.alter_column(table_name='dag', column_name='last_pickled',
                        type_=mysql.DATETIME(fsp=6))
        op.alter_column(table_name='dag', column_name='last_expired',
                        type_=mysql.DATETIME(fsp=6))

        op.alter_column(table_name='dag_pickle', column_name='created_dttm',
                        type_=mysql.DATETIME(fsp=6))

        op.alter_column(table_name='dag_run', column_name='execution_date',
                        type_=mysql.DATETIME(fsp=6))
        op.alter_column(table_name='dag_run', column_name='start_date',
                        type_=mysql.DATETIME(fsp=6))
        op.alter_column(table_name='dag_run', column_name='end_date',
                        type_=mysql.DATETIME(fsp=6))

        op.alter_column(table_name='import_error', column_name='timestamp',
                        type_=mysql.DATETIME(fsp=6))

        op.alter_column(table_name='job', column_name='start_date',
                        type_=mysql.DATETIME(fsp=6))
        op.alter_column(table_name='job', column_name='end_date',
                        type_=mysql.DATETIME(fsp=6))
        op.alter_column(table_name='job', column_name='latest_heartbeat',
                        type_=mysql.DATETIME(fsp=6))

        op.alter_column(table_name='log', column_name='dttm',
                        type_=mysql.DATETIME(fsp=6))
        op.alter_column(table_name='log', column_name='execution_date',
                        type_=mysql.DATETIME(fsp=6))

        op.alter_column(table_name='sla_miss', column_name='execution_date',
                        type_=mysql.DATETIME(fsp=6),
                        nullable=False)
        op.alter_column(table_name='sla_miss', column_name='timestamp',
                        type_=mysql.DATETIME(fsp=6))

        op.alter_column(table_name='task_fail', column_name='execution_date',
                        type_=mysql.DATETIME(fsp=6))
        op.alter_column(table_name='task_fail', column_name='start_date',
                        type_=mysql.DATETIME(fsp=6))
        op.alter_column(table_name='task_fail', column_name='end_date',
                        type_=mysql.DATETIME(fsp=6))

        op.alter_column(table_name='task_instance', column_name='execution_date',
                        type_=mysql.DATETIME(fsp=6),
                        nullable=False)
        op.alter_column(table_name='task_instance', column_name='start_date',
                        type_=mysql.DATETIME(fsp=6))
        op.alter_column(table_name='task_instance', column_name='end_date',
                        type_=mysql.DATETIME(fsp=6))
        op.alter_column(table_name='task_instance', column_name='queued_dttm',
                        type_=mysql.DATETIME(fsp=6))

        op.alter_column(table_name='xcom', column_name='timestamp',
                        type_=mysql.DATETIME(fsp=6))
        op.alter_column(table_name='xcom', column_name='execution_date',
                        type_=mysql.DATETIME(fsp=6)) 
開發者ID:apache,項目名稱:airflow,代碼行數:63,代碼來源:4addfa1236f1_add_fractional_seconds_to_mysql_tables.py

示例14: downgrade

# 需要導入模塊: from sqlalchemy.dialects import mysql [as 別名]
# 或者: from sqlalchemy.dialects.mysql import DATETIME [as 別名]
def downgrade():   # noqa: D103
    if context.config.get_main_option('sqlalchemy.url').startswith('mysql'):
        op.alter_column(table_name='dag', column_name='last_scheduler_run',
                        type_=mysql.DATETIME())
        op.alter_column(table_name='dag', column_name='last_pickled',
                        type_=mysql.DATETIME())
        op.alter_column(table_name='dag', column_name='last_expired',
                        type_=mysql.DATETIME())

        op.alter_column(table_name='dag_pickle', column_name='created_dttm',
                        type_=mysql.DATETIME())

        op.alter_column(table_name='dag_run', column_name='execution_date',
                        type_=mysql.DATETIME())
        op.alter_column(table_name='dag_run', column_name='start_date',
                        type_=mysql.DATETIME())
        op.alter_column(table_name='dag_run', column_name='end_date',
                        type_=mysql.DATETIME())

        op.alter_column(table_name='import_error', column_name='timestamp',
                        type_=mysql.DATETIME())

        op.alter_column(table_name='job', column_name='start_date',
                        type_=mysql.DATETIME())
        op.alter_column(table_name='job', column_name='end_date',
                        type_=mysql.DATETIME())
        op.alter_column(table_name='job', column_name='latest_heartbeat',
                        type_=mysql.DATETIME())

        op.alter_column(table_name='log', column_name='dttm',
                        type_=mysql.DATETIME())
        op.alter_column(table_name='log', column_name='execution_date',
                        type_=mysql.DATETIME())

        op.alter_column(table_name='sla_miss', column_name='execution_date',
                        type_=mysql.DATETIME(), nullable=False)
        op.alter_column(table_name='sla_miss', column_name='timestamp',
                        type_=mysql.DATETIME())

        op.alter_column(table_name='task_fail', column_name='execution_date',
                        type_=mysql.DATETIME())
        op.alter_column(table_name='task_fail', column_name='start_date',
                        type_=mysql.DATETIME())
        op.alter_column(table_name='task_fail', column_name='end_date',
                        type_=mysql.DATETIME())

        op.alter_column(table_name='task_instance', column_name='execution_date',
                        type_=mysql.DATETIME(),
                        nullable=False)
        op.alter_column(table_name='task_instance', column_name='start_date',
                        type_=mysql.DATETIME())
        op.alter_column(table_name='task_instance', column_name='end_date',
                        type_=mysql.DATETIME())
        op.alter_column(table_name='task_instance', column_name='queued_dttm',
                        type_=mysql.DATETIME())

        op.alter_column(table_name='xcom', column_name='timestamp',
                        type_=mysql.DATETIME())
        op.alter_column(table_name='xcom', column_name='execution_date',
                        type_=mysql.DATETIME()) 
開發者ID:apache,項目名稱:airflow,代碼行數:62,代碼來源:4addfa1236f1_add_fractional_seconds_to_mysql_tables.py

示例15: import_coin_info

# 需要導入模塊: from sqlalchemy.dialects import mysql [as 別名]
# 或者: from sqlalchemy.dialects.mysql import DATETIME [as 別名]
def import_coin_info(chain_param=None, ):
    """插入基礎信息數據到 cmc_coin_v1_info"""
    table_name = "cmc_coin_v1_info"
    logging.info("更新 %s 開始", table_name)
    has_table = engine_md.has_table(table_name)
    # url = 'https://api.coinmarketcap.com/v2/listings/'
    # dtype = {
    #     'id': String(60),
    #     'name': String(60),
    #     'symbol': String(20),
    #     'website_slug': String(60),
    # }

    url = 'https://api.coinmarketcap.com/v1/ticker/?limit=0'
    dtype = {
        'id': String(60),
        'name': String(60),
        'symbol': String(20),
        'rank': Integer,
        'price_usd': DOUBLE,
        'price_btc': DOUBLE,
        '24h_volume_usd': DOUBLE,
        'market_cap_usd': DOUBLE,
        'available_supply': DOUBLE,
        'total_supply': DOUBLE,
        'max_supply': DOUBLE,
        'percent_change_1h': DOUBLE,
        'percent_change_24h': DOUBLE,
        'percent_change_7d': DOUBLE,
        'last_updated': DATETIME,
    }
    rsp = requests.get(url)
    if rsp.status_code != 200:
        raise ValueError('請求 listings 相應失敗')
    json = rsp.json()
    data_df = pd.DataFrame(json)
    data_df['last_updated'] = data_df['last_updated'].apply(
        lambda x: None if x is None else datetime.datetime.fromtimestamp(float(x)))
    data_count = bunch_insert_on_duplicate_update(data_df, table_name, engine_md, dtype=dtype)
    logging.info("更新 %s 完成 存量數據 %d 條", table_name, data_count)
    if not has_table and engine_md.has_table(table_name):
        alter_table_2_myisam(engine_md, [table_name])
        # build_primary_key([table_name])
        create_pk_str = """ALTER TABLE {table_name}
        CHANGE COLUMN `id` `id` VARCHAR(60) NOT NULL FIRST ,
        ADD PRIMARY KEY (`id`)""".format(table_name=table_name)
        with with_db_session(engine_md) as session:
            session.execute(create_pk_str)

    # 更新 code_mapping 表
    # update_from_info_table(table_name) 
開發者ID:DataIntegrationAlliance,項目名稱:data_integration_celery,代碼行數:53,代碼來源:coin.py


注:本文中的sqlalchemy.dialects.mysql.DATETIME屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。