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


Python sqlalchemy.TIMESTAMP屬性代碼示例

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


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

示例1: upgrade

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import TIMESTAMP [as 別名]
def upgrade():
    periodic_table = op.create_table(
        'opendaylight_periodic_task',
        sa.Column('state', sa.Enum(odl_const.PENDING, odl_const.PROCESSING,
                                   name='state'),
                  nullable=False),
        sa.Column('processing_operation', sa.String(70)),
        sa.Column('task', sa.String(70), primary_key=True),
        sa.Column('lock_updated', sa.TIMESTAMP, nullable=False,
                  server_default=sa.func.now(),
                  onupdate=sa.func.now())
    )
    op.bulk_insert(periodic_table,
                   [{'task': 'maintenance',
                     'state': odl_const.PENDING},
                    {'task': 'hostconfig',
                     'state': odl_const.PENDING}]) 
開發者ID:openstack,項目名稱:networking-odl,代碼行數:19,代碼來源:6f7dfb241354_create_opendaylight_preiodic_task_table.py

示例2: test_mysql_timestamp

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import TIMESTAMP [as 別名]
def test_mysql_timestamp(metadata):
    Table("simple", metadata, Column("id", INTEGER, primary_key=True), Column("timestamp", mysql.TIMESTAMP))

    assert (
        generate_code(metadata)
        == """\
# coding: utf-8
from sqlalchemy import Column, Integer, TIMESTAMP
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()
metadata = Base.metadata


class Simple(Base):
    __tablename__ = 'simple'

    id = Column(Integer, primary_key=True)
    timestamp = Column(TIMESTAMP)
"""
    ) 
開發者ID:thomaxxl,項目名稱:safrs,代碼行數:23,代碼來源:test_codegen.py

示例3: upgrade

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import TIMESTAMP [as 別名]
def upgrade():
    op.create_table(
        'opendaylightjournal',
        sa.Column('id', sa.String(36), primary_key=True),
        sa.Column('object_type', sa.String(36), nullable=False),
        sa.Column('object_uuid', sa.String(36), nullable=False),
        sa.Column('operation', sa.String(36), nullable=False),
        sa.Column('data', sa.PickleType, nullable=True),
        sa.Column('state',
                  sa.Enum('pending', 'processing', 'failed', 'completed',
                          name='state'),
                  nullable=False, default='pending'),
        sa.Column('retry_count', sa.Integer, default=0),
        sa.Column('created_at', sa.DateTime, default=sa.func.now()),
        sa.Column('last_retried', sa.TIMESTAMP, server_default=sa.func.now(),
                  onupdate=sa.func.now())
    ) 
開發者ID:openstack,項目名稱:networking-odl,代碼行數:19,代碼來源:37e242787ae5_opendaylight_neutron_mechanism_driver_.py

示例4: upgrade

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import TIMESTAMP [as 別名]
def upgrade():
    maint_table = op.create_table(
        'opendaylight_maintenance',
        sa.Column('id', sa.String(36), primary_key=True),
        sa.Column('state', sa.Enum(odl_const.PENDING, odl_const.PROCESSING,
                                   name='state'),
                  nullable=False),
        sa.Column('processing_operation', sa.String(70)),
        sa.Column('lock_updated', sa.TIMESTAMP, nullable=False,
                  server_default=sa.func.now(),
                  onupdate=sa.func.now())
    )

    # Insert the only row here that is used to synchronize the lock between
    # different Neutron processes.
    op.bulk_insert(maint_table,
                   [{'id': uuidutils.generate_uuid(),
                     'state': odl_const.PENDING}]) 
開發者ID:openstack,項目名稱:networking-odl,代碼行數:20,代碼來源:703dbf02afde_add_journal_maintenance_table.py

示例5: upgrade

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import TIMESTAMP [as 別名]
def upgrade():
    op.create_table(
        'opendaylightjournal_new',
        sa.Column('seqnum', sa.BigInteger(),
                  primary_key=True, autoincrement=True),
        sa.Column('object_type', sa.String(36), nullable=False),
        sa.Column('object_uuid', sa.String(36), nullable=False),
        sa.Column('operation', sa.String(36), nullable=False),
        sa.Column('data', sa.PickleType, nullable=True),
        sa.Column('state',
                  sa.Enum('pending', 'processing', 'failed', 'completed',
                          name='state'),
                  nullable=False, default='pending'),
        sa.Column('retry_count', sa.Integer, default=0),
        sa.Column('created_at', sa.DateTime, default=sa.func.now()),
        sa.Column('last_retried', sa.TIMESTAMP, server_default=sa.func.now(),
                  onupdate=sa.func.now()),
    ) 
開發者ID:openstack,項目名稱:networking-odl,代碼行數:20,代碼來源:3d560427d776_add_sequence_number_to_journal.py

示例6: test_reflect_select

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import TIMESTAMP [as 別名]
def test_reflect_select(table, table_using_test_dataset):
    for table in [table, table_using_test_dataset]:
        assert len(table.c) == 18

        assert isinstance(table.c.integer, Column)
        assert isinstance(table.c.integer.type, types.Integer)
        assert isinstance(table.c.timestamp.type, types.TIMESTAMP)
        assert isinstance(table.c.string.type, types.String)
        assert isinstance(table.c.float.type, types.Float)
        assert isinstance(table.c.boolean.type, types.Boolean)
        assert isinstance(table.c.date.type, types.DATE)
        assert isinstance(table.c.datetime.type, types.DATETIME)
        assert isinstance(table.c.time.type, types.TIME)
        assert isinstance(table.c.bytes.type, types.BINARY)
        assert isinstance(table.c['record.age'].type, types.Integer)
        assert isinstance(table.c['record.name'].type, types.String)
        assert isinstance(table.c['nested_record.record.age'].type, types.Integer)
        assert isinstance(table.c['nested_record.record.name'].type, types.String)
        assert isinstance(table.c.array.type, types.ARRAY)

        rows = table.select().execute().fetchall()
        assert len(rows) == 1000 
開發者ID:mxmzdlv,項目名稱:pybigquery,代碼行數:24,代碼來源:test_sqlalchemy_bigquery.py

示例7: setUp

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import TIMESTAMP [as 別名]
def setUp(self):
        self.sa_meta = sa.MetaData()
        self.data = [
            [17.124, 1.12, 3.14, 13.37],
            [1, 2, 3, 4],
            [1, 2, 3, 4],
            [1, 2, 3, 4],
            [True, None, False, True],
            ['string 1', 'string 2', None, 'string 3'],
            [datetime(2007, 7, 13, 1, 23, 34, 123456),
             None,
             datetime(2006, 1, 13, 12, 34, 56, 432539),
             datetime(2010, 8, 13, 5, 46, 57, 437699), ],
            ["Test Text", "Some#More#Test#  Text", "!@#$%%^&*&", None],
        ]
        self.table = sa.Table(
            'unit_test_table',
            self.sa_meta,
            sa.Column('real_col', sa.REAL),
            sa.Column('bigint_col', sa.BIGINT),
            sa.Column('int_col', sa.INTEGER),
            sa.Column('smallint_col', sa.SMALLINT),
            sa.Column('bool_col', sa.BOOLEAN),
            sa.Column('str_col', sa.VARCHAR),
            sa.Column('timestamp_col', sa.TIMESTAMP),
            sa.Column('plaintext_col', sa.TEXT),
        )

        self.expected_datatypes = [
            pa.float32(),
            pa.int64(),
            pa.int32(),
            pa.int16(),
            pa.bool_(),
            pa.string(),
            pa.timestamp('ns'),
            pa.string(),
        ] 
開發者ID:hellonarrativ,項目名稱:spectrify,代碼行數:40,代碼來源:test_parquet.py

示例8: mysql_timestamp

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import TIMESTAMP [as 別名]
def mysql_timestamp():   # noqa: D103
    return mysql.TIMESTAMP(fsp=6) 
開發者ID:apache,項目名稱:airflow,代碼行數:4,代碼來源:0a2a5b66e19d_add_task_reschedule_table.py

示例9: sa_timestamp

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import TIMESTAMP [as 別名]
def sa_timestamp():   # noqa: D103
    return sa.TIMESTAMP(timezone=True) 
開發者ID:apache,項目名稱:airflow,代碼行數:4,代碼來源:0a2a5b66e19d_add_task_reschedule_table.py

示例10: upgrade

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import TIMESTAMP [as 別名]
def upgrade():
    """Apply Add RenderedTaskInstanceFields table"""
    json_type = sa.JSON
    conn = op.get_bind()  # pylint: disable=no-member

    if conn.dialect.name != "postgresql":
        # Mysql 5.7+/MariaDB 10.2.3 has JSON support. Rather than checking for
        # versions, check for the function existing.
        try:
            conn.execute("SELECT JSON_VALID(1)").fetchone()
        except (sa.exc.OperationalError, sa.exc.ProgrammingError):
            json_type = sa.Text

    op.create_table(
        TABLE_NAME,  # pylint: disable=no-member
        sa.Column('dag_id', sa.String(length=250), nullable=False),
        sa.Column('task_id', sa.String(length=250), nullable=False),
        sa.Column('execution_date', sa.TIMESTAMP(timezone=True), nullable=False),
        sa.Column('rendered_fields', json_type(), nullable=False),
        sa.PrimaryKeyConstraint('dag_id', 'task_id', 'execution_date')
    ) 
開發者ID:apache,項目名稱:airflow,代碼行數:23,代碼來源:852ae6c715af_add_rendered_task_instance_fields_table.py

示例11: test_alter_column_modify_datetime_default

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import TIMESTAMP [as 別名]
def test_alter_column_modify_datetime_default(self):
        # use CHANGE format when the datatype is DATETIME or TIMESTAMP,
        # as this is needed for a functional default which is what you'd
        # get with a DATETIME/TIMESTAMP.  Will also work in the very unlikely
        # case the default is a fixed timestamp value.
        context = op_fixture("mysql")
        op.alter_column(
            "t",
            "c",
            existing_type=DATETIME(),
            server_default=text("CURRENT_TIMESTAMP"),
        )
        context.assert_(
            "ALTER TABLE t CHANGE c c DATETIME NULL DEFAULT CURRENT_TIMESTAMP"
        ) 
開發者ID:sqlalchemy,項目名稱:alembic,代碼行數:17,代碼來源:test_mysql.py

示例12: test_add_timestamp_server_default_current_timestamp

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import TIMESTAMP [as 別名]
def test_add_timestamp_server_default_current_timestamp(self):
        self._run_alter_col(
            {"type": TIMESTAMP()},
            {"server_default": text("CURRENT_TIMESTAMP")},
        ) 
開發者ID:sqlalchemy,項目名稱:alembic,代碼行數:7,代碼來源:test_mysql.py

示例13: test_add_timestamp_server_default_now

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import TIMESTAMP [as 別名]
def test_add_timestamp_server_default_now(self):
        self._run_alter_col(
            {"type": TIMESTAMP()},
            {"server_default": text("NOW()")},
            compare={"server_default": text("CURRENT_TIMESTAMP")},
        ) 
開發者ID:sqlalchemy,項目名稱:alembic,代碼行數:8,代碼來源:test_mysql.py

示例14: test_add_timestamp_server_default_current_timestamp_bundle_onupdate

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import TIMESTAMP [as 別名]
def test_add_timestamp_server_default_current_timestamp_bundle_onupdate(
        self,
    ):
        # note SQLAlchemy reflection bundles the ON UPDATE part into the
        # server default reflection see
        # https://github.com/sqlalchemy/sqlalchemy/issues/4652
        self._run_alter_col(
            {"type": TIMESTAMP()},
            {
                "server_default": text(
                    "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"
                )
            },
        ) 
開發者ID:sqlalchemy,項目名稱:alembic,代碼行數:16,代碼來源:test_mysql.py

示例15: test_compare_timestamp_current_timestamp_diff

# 需要導入模塊: import sqlalchemy [as 別名]
# 或者: from sqlalchemy import TIMESTAMP [as 別名]
def test_compare_timestamp_current_timestamp_diff(self):
        self._compare_default_roundtrip(TIMESTAMP(), None, "CURRENT_TIMESTAMP") 
開發者ID:sqlalchemy,項目名稱:alembic,代碼行數:4,代碼來源:test_mysql.py


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