Python sqlalchemy 模块,TIMESTAMP 实例源码

我们从Python开源项目中,提取了以下39个代码示例,用于说明如何使用sqlalchemy.TIMESTAMP

项目:flasky    作者:RoseOu    | 项目源码 | 文件源码
def __init__(self, timezone=False, fsp=None):
        """Construct a MySQL TIMESTAMP type.

        :param timezone: not used by the MySQL dialect.
        :param fsp: fractional seconds precision value.
         MySQL 5.6.4 supports storage of fractional seconds;
         this parameter will be used when emitting DDL
         for the TIMESTAMP type.

         .. note::

            DBAPI driver support for fractional seconds may
            be limited; current support includes
            MySQL Connector/Python.

        .. versionadded:: 0.8.5 Added MySQL-specific :class:`.mysql.TIMESTAMP`
           with fractional seconds support.

        """
        super(TIMESTAMP, self).__init__(timezone=timezone)
        self.fsp = fsp
项目:flasky    作者:RoseOu    | 项目源码 | 文件源码
def visit_typeclause(self, typeclause):
        type_ = typeclause.type.dialect_impl(self.dialect)
        if isinstance(type_, sqltypes.Integer):
            if getattr(type_, 'unsigned', False):
                return 'UNSIGNED INTEGER'
            else:
                return 'SIGNED INTEGER'
        elif isinstance(type_, sqltypes.TIMESTAMP):
            return 'DATETIME'
        elif isinstance(type_, (sqltypes.DECIMAL, sqltypes.DateTime,
                                sqltypes.Date, sqltypes.Time)):
            return self.dialect.type_compiler.process(type_)
        elif isinstance(type_, sqltypes.String) \
                and not isinstance(type_, (ENUM, SET)):
            adapted = CHAR._adapt_string_for_cast(type_)
            return self.dialect.type_compiler.process(adapted)
        elif isinstance(type_, sqltypes._Binary):
            return 'BINARY'
        elif isinstance(type_, sqltypes.NUMERIC):
            return self.dialect.type_compiler.process(
                type_).replace('NUMERIC', 'DECIMAL')
        else:
            return None
项目:flasky    作者:RoseOu    | 项目源码 | 文件源码
def get_column_specification(self, column, **kw):
        """Builds column DDL."""

        colspec = [self.preparer.format_column(column),
                   self.dialect.type_compiler.process(column.type)
                   ]

        default = self.get_column_default_string(column)
        if default is not None:
            colspec.append('DEFAULT ' + default)

        is_timestamp = isinstance(column.type, sqltypes.TIMESTAMP)
        if not column.nullable and not is_timestamp:
            colspec.append('NOT NULL')

        # see: http://docs.sqlalchemy.org/en/latest/dialects/
        #   mysql.html#mysql_timestamp_null
        elif column.nullable and is_timestamp and default is None:
            colspec.append('NULL')

        if column is column.table._autoincrement_column and \
                column.server_default is None:
            colspec.append('AUTO_INCREMENT')

        return ' '.join(colspec)
项目:oa_qian    作者:sunqb    | 项目源码 | 文件源码
def __init__(self, timezone=False, fsp=None):
        """Construct a MySQL TIMESTAMP type.

        :param timezone: not used by the MySQL dialect.
        :param fsp: fractional seconds precision value.
         MySQL 5.6.4 supports storage of fractional seconds;
         this parameter will be used when emitting DDL
         for the TIMESTAMP type.

         .. note::

            DBAPI driver support for fractional seconds may
            be limited; current support includes
            MySQL Connector/Python.

        .. versionadded:: 0.8.5 Added MySQL-specific :class:`.mysql.TIMESTAMP`
           with fractional seconds support.

        """
        super(TIMESTAMP, self).__init__(timezone=timezone)
        self.fsp = fsp
项目:oa_qian    作者:sunqb    | 项目源码 | 文件源码
def visit_typeclause(self, typeclause):
        type_ = typeclause.type.dialect_impl(self.dialect)
        if isinstance(type_, sqltypes.Integer):
            if getattr(type_, 'unsigned', False):
                return 'UNSIGNED INTEGER'
            else:
                return 'SIGNED INTEGER'
        elif isinstance(type_, sqltypes.TIMESTAMP):
            return 'DATETIME'
        elif isinstance(type_, (sqltypes.DECIMAL, sqltypes.DateTime,
                                sqltypes.Date, sqltypes.Time)):
            return self.dialect.type_compiler.process(type_)
        elif isinstance(type_, sqltypes.String) \
                and not isinstance(type_, (ENUM, SET)):
            adapted = CHAR._adapt_string_for_cast(type_)
            return self.dialect.type_compiler.process(adapted)
        elif isinstance(type_, sqltypes._Binary):
            return 'BINARY'
        elif isinstance(type_, sqltypes.NUMERIC):
            return self.dialect.type_compiler.process(
                type_).replace('NUMERIC', 'DECIMAL')
        else:
            return None
项目:oa_qian    作者:sunqb    | 项目源码 | 文件源码
def get_column_specification(self, column, **kw):
        """Builds column DDL."""

        colspec = [self.preparer.format_column(column),
                   self.dialect.type_compiler.process(column.type)
                   ]

        default = self.get_column_default_string(column)
        if default is not None:
            colspec.append('DEFAULT ' + default)

        is_timestamp = isinstance(column.type, sqltypes.TIMESTAMP)
        if not column.nullable and not is_timestamp:
            colspec.append('NOT NULL')

        # see: http://docs.sqlalchemy.org/en/latest/dialects/
        #   mysql.html#mysql_timestamp_null
        elif column.nullable and is_timestamp and default is None:
            colspec.append('NULL')

        if column is column.table._autoincrement_column and \
                column.server_default is None:
            colspec.append('AUTO_INCREMENT')

        return ' '.join(colspec)
项目:FlaskBackend    作者:iamrajhans    | 项目源码 | 文件源码
def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.alter_column(u'users', 'user_id',
               existing_type=sa.VARCHAR(length=100),
               nullable=True)
    op.alter_column(u'users', 'updated_at',
               existing_type=postgresql.TIMESTAMP(),
               nullable=True)
    op.alter_column(u'users', 'name',
               existing_type=sa.VARCHAR(length=100),
               nullable=True)
    op.alter_column(u'users', 'last_name',
               existing_type=sa.VARCHAR(length=200),
               nullable=True)
    op.alter_column(u'users', 'email',
               existing_type=sa.VARCHAR(length=150),
               nullable=True)
    op.alter_column(u'users', 'created_at',
               existing_type=postgresql.TIMESTAMP(),
               nullable=True)
    op.drop_table('request_referral')
    ### end Alembic commands ###
项目:zeus    作者:getsentry    | 项目源码 | 文件源码
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('email',
                    sa.Column('user_id', zeus.db.types.guid.GUID(),
                              nullable=False),
                    sa.Column('email', sa.String(length=128), nullable=False),
                    sa.Column('verified', sa.Boolean(), nullable=True),
                    sa.Column('id', zeus.db.types.guid.GUID(), nullable=False),
                    sa.Column('date_created', sa.TIMESTAMP(timezone=True),
                              server_default=sa.text('now()'), nullable=False),
                    sa.ForeignKeyConstraint(
                        ['user_id'], ['user.id'], ondelete='CASCADE'),
                    sa.PrimaryKeyConstraint('id'),
                    sa.UniqueConstraint('user_id', 'email',
                                        name='unq_user_email')
                    )
    op.create_index(op.f('ix_email_user_id'), 'email',
                    ['user_id'], unique=False)
    # ### end Alembic commands ###
项目:zeus    作者:getsentry    | 项目源码 | 文件源码
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'failurereason',
        sa.Column('job_id', zeus.db.types.guid.GUID(), nullable=False),
        sa.Column('reason', zeus.db.types.enum.StrEnum(), nullable=False),
        sa.Column('repository_id', zeus.db.types.guid.GUID(), nullable=False),
        sa.Column('id', zeus.db.types.guid.GUID(), nullable=False),
        sa.Column(
            'date_created',
            sa.TIMESTAMP(timezone=True),
            server_default=sa.text('now()'),
            nullable=False
        ),
        sa.ForeignKeyConstraint(['job_id'], ['job.id'], ondelete='CASCADE'),
        sa.ForeignKeyConstraint(['repository_id'], ['repository.id'], ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('job_id', 'reason', name='unq_failurereason_key')
    )
    op.create_index(
        op.f('ix_failurereason_repository_id'), 'failurereason', ['repository_id'], unique=False
    )
    # ### end Alembic commands ###
项目:Albireo    作者:lordfriend    | 项目源码 | 文件源码
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('web_hook',
    sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
    sa.Column('name', sa.TEXT(), nullable=False, unique=True),
    sa.Column('description', sa.TEXT(), nullable=True),
    sa.Column('url', sa.TEXT(), nullable=False),
    sa.Column('shared_secret', sa.TEXT(), nullable=False),
    sa.Column('status', sa.Integer(), nullable=False),
    sa.Column('consecutive_failure_count', sa.Integer(), nullable=False),
    sa.Column('register_time', sa.TIMESTAMP(), nullable=False),
    sa.Column('created_by_uid', postgresql.UUID(as_uuid=True), nullable=True),
    sa.Column('permissions', sa.TEXT(), nullable=False, server_default='"[]"'),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('web_hook_token',
    sa.Column('token_id', sa.TEXT(), nullable=False),
    sa.Column('user_id', postgresql.UUID(as_uuid=True), nullable=False),
    sa.Column('web_hook_id', postgresql.UUID(as_uuid=True), nullable=False),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
    sa.ForeignKeyConstraint(['web_hook_id'], ['web_hook.id'], ),
    sa.PrimaryKeyConstraint('user_id', 'web_hook_id')
    )
    # ### end Alembic commands ###
项目:Albireo    作者:lordfriend    | 项目源码 | 文件源码
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('favorites',
    sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
    sa.Column('user_id', postgresql.UUID(as_uuid=True), nullable=False),
    sa.Column('bangumi_id', postgresql.UUID(as_uuid=True), nullable=False),
    sa.Column('status', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['bangumi_id'], ['bangumi.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('watch_progress',
    sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
    sa.Column('user_id', postgresql.UUID(as_uuid=True), nullable=False),
    sa.Column('bangumi_id', postgresql.UUID(as_uuid=True), nullable=False),
    sa.Column('episode_id', postgresql.UUID(as_uuid=True), nullable=False),
    sa.Column('watch_status', sa.Integer(), nullable=False),
    sa.Column('last_watch_position', sa.Integer(), nullable=True),
    sa.Column('last_watch_time', sa.TIMESTAMP(), nullable=True),
    sa.ForeignKeyConstraint(['bangumi_id'], ['bangumi.id'], ),
    sa.ForeignKeyConstraint(['episode_id'], ['episodes.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    ### end Alembic commands ###
项目:flasky    作者:RoseOu    | 项目源码 | 文件源码
def visit_TIMESTAMP(self, type_):
        if getattr(type_, 'fsp', None):
            return "TIMESTAMP(%d)" % type_.fsp
        else:
            return "TIMESTAMP"
项目:oa_qian    作者:sunqb    | 项目源码 | 文件源码
def visit_TIMESTAMP(self, type_):
        if getattr(type_, 'fsp', None):
            return "TIMESTAMP(%d)" % type_.fsp
        else:
            return "TIMESTAMP"
项目:RSVPBot    作者:recursecenter    | 项目源码 | 文件源码
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('event', sa.Column('created_by', sa.String(), nullable=True))
    op.add_column('event', sa.Column('end_time', sa.TIMESTAMP(timezone=True), nullable=True))
    op.add_column('event', sa.Column('start_time', sa.TIMESTAMP(timezone=True), nullable=True))
    op.add_column('event', sa.Column('url', sa.String(), nullable=True))
    # ### end Alembic commands ###
项目:RSVPBot    作者:recursecenter    | 项目源码 | 文件源码
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('event', sa.Column('created_at', sa.TIMESTAMP(timezone=True), nullable=True))
    # ### end Alembic commands ###
项目:FlaskBackend    作者:iamrajhans    | 项目源码 | 文件源码
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('users', sa.Column('address', sa.String(length=255), nullable=True))
    op.add_column('users', sa.Column('birth_date', sa.TIMESTAMP(), nullable=True))
    op.add_column('users', sa.Column('created_at', sa.TIMESTAMP(), nullable=True))
    op.add_column('users', sa.Column('last_name', sa.String(length=200), nullable=True))
    op.add_column('users', sa.Column('updated_at', sa.TIMESTAMP(), nullable=True))
    op.add_column('users', sa.Column('user_id', sa.String(length=100), nullable=True))
    ### end Alembic commands ###
项目:FlaskBackend    作者:iamrajhans    | 项目源码 | 文件源码
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('user_session',
    sa.Column('id', sa.String(length=255), nullable=False),
    sa.Column('user_id', sa.String(length=100), nullable=False),
    sa.Column('session_start', sa.TIMESTAMP(), nullable=False),
    sa.Column('session_end', sa.TIMESTAMP(), nullable=False),
    sa.Column('isValid', sa.Boolean(), nullable=False),
    sa.Column('user_plan', sa.String(length=255), nullable=False),
    sa.Column('created_at', sa.TIMESTAMP(), nullable=False),
    sa.Column('updated_at', sa.TIMESTAMP(), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    ### end Alembic commands ###
项目:FlaskBackend    作者:iamrajhans    | 项目源码 | 文件源码
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('request_referral',
    sa.Column('id', sa.String(length=255), nullable=False),
    sa.Column('user_id', sa.String(length=100), nullable=True),
    sa.Column('from_user', sa.String(length=255), nullable=False),
    sa.Column('to_user', sa.String(length=255), nullable=False),
    sa.Column('request_type', sa.String(length=255), nullable=False),
    sa.Column('referral_id', sa.String(length=255), nullable=False),
    sa.Column('created_at', sa.TIMESTAMP(), nullable=True),
    sa.Column('updated_at', sa.TIMESTAMP(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.alter_column(u'users', 'created_at',
               existing_type=postgresql.TIMESTAMP(),
               nullable=False)
    op.alter_column(u'users', 'email',
               existing_type=sa.VARCHAR(length=150),
               nullable=False)
    op.alter_column(u'users', 'last_name',
               existing_type=sa.VARCHAR(length=200),
               nullable=False)
    op.alter_column(u'users', 'name',
               existing_type=sa.VARCHAR(length=100),
               nullable=False)
    op.alter_column(u'users', 'updated_at',
               existing_type=postgresql.TIMESTAMP(),
               nullable=False)
    op.alter_column(u'users', 'user_id',
               existing_type=sa.VARCHAR(length=100),
               nullable=False)
    ### end Alembic commands ###
项目:zeus    作者:getsentry    | 项目源码 | 文件源码
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column(
        'artifact',
        sa.Column(
            'date_finished',
            sa.TIMESTAMP(
                timezone=True),
            nullable=True))
    op.add_column('artifact', sa.Column('date_started', sa.TIMESTAMP(timezone=True), nullable=True))
    op.add_column('artifact', sa.Column('date_updated', sa.TIMESTAMP(timezone=True), nullable=True))
    # ### end Alembic commands ###
项目:zeus    作者:getsentry    | 项目源码 | 文件源码
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('job', sa.Column('date_updated', sa.TIMESTAMP(timezone=True), nullable=True))
    # ### end Alembic commands ###
项目:zeus    作者:getsentry    | 项目源码 | 文件源码
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('styleviolation',
                    sa.Column('job_id', zeus.db.types.guid.GUID(), nullable=False),
                    sa.Column('filename', sa.Text(), nullable=False),
                    sa.Column('severity', zeus.db.types.enum.Enum(), nullable=False),
                    sa.Column('message', sa.Text(), nullable=False),
                    sa.Column('lineno', sa.Integer(), nullable=True),
                    sa.Column('colno', sa.Integer(), nullable=True),
                    sa.Column('source', sa.Text(), nullable=True),
                    sa.Column('repository_id', zeus.db.types.guid.GUID(), nullable=False),
                    sa.Column('id', zeus.db.types.guid.GUID(), nullable=False),
                    sa.Column(
                        'date_created',
                        sa.TIMESTAMP(
                            timezone=True),
                        server_default=sa.text('now()'),
                        nullable=False),
                    sa.ForeignKeyConstraint(['job_id'], ['job.id'], ondelete='CASCADE'),
                    sa.ForeignKeyConstraint(
                        ['repository_id'], ['repository.id'], ondelete='CASCADE'),
                    sa.PrimaryKeyConstraint('id')
                    )
    op.create_index(
        op.f('ix_styleviolation_repository_id'),
        'styleviolation',
        ['repository_id'],
        unique=False)
    # ### end Alembic commands ###
项目:pyiem    作者:rheineke    | 项目源码 | 文件源码
def quotes_table(metadata, market):
    table_name = quote_key(market)

    # Index columns
    ts_col = sa.Column('Timestamp', sa.TIMESTAMP, nullable=False)
    asset_col = sa.Column(
        config.ASSET_ID,
        sa.INTEGER,
        sa.ForeignKey(config.ASSETS + '.' + config.ID),
        nullable=False
    )

    return sa.Table(
        table_name,
        metadata,
        ts_col,
        asset_col,
        sa.Column('Bid', sa.INTEGER, nullable=False),  # No example of nullable
        sa.Column('Ask', sa.INTEGER, nullable=False),
        sa.Column('Last', sa.INTEGER, nullable=False),
        sa.Column('Low', sa.INTEGER, nullable=True),
        sa.Column('High', sa.INTEGER, nullable=True),
        sa.Column('Average', sa.DECIMAL, nullable=True),
        sa.Index('idx', asset_col, ts_col, unique=True),
    )
项目:networking-vpp    作者:openstack    | 项目源码 | 文件源码
def upgrade():
    op.create_table('vpp_etcd_journal',
                    sa.Column('id', sa.Integer, primary_key=True,
                              autoincrement=True, nullable=False),
                    sa.Column('k', sa.String(255), nullable=False),
                    sa.Column('v', sa.PickleType, nullable=True),
                    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()))
项目:pgawedge    作者:portfoliome    | 项目源码 | 文件源码
def test_utcnow_compile(self):
        column = sa.Column('mycol', sa.TIMESTAMP(timezone=True),
                           server_default=utcnow())
        expected = "mycol TIMESTAMP WITH TIME ZONE DEFAULT TIMEZONE('utc', CURRENT_TIMESTAMP)"

        self._check_column_ddl(expected, column)
项目:Albireo    作者:lordfriend    | 项目源码 | 文件源码
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('task',
    sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
    sa.Column('type', sa.Integer(), nullable=False),
    sa.Column('content', sa.TEXT(), nullable=True),
    sa.Column('status', sa.Integer(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.add_column(u'bangumi', sa.Column('delete_mark', sa.TIMESTAMP(), nullable=True))
    op.add_column(u'episodes', sa.Column('delete_mark', sa.TIMESTAMP(), nullable=True))
    # ### end Alembic commands ###
项目:Albireo    作者:lordfriend    | 项目源码 | 文件源码
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('users', sa.Column('email', sa.String(length=512), unique=True, nullable=True))
    op.add_column('users', sa.Column('email_confirmed', sa.BOOLEAN(), nullable=False, server_default=sa.false()))
    op.add_column('users', sa.Column('register_time', sa.TIMESTAMP(), nullable=False, server_default=sa.func.now()))
    op.add_column('users', sa.Column('update_time', sa.TIMESTAMP(), nullable=False, server_default=sa.func.now()))
    ### end Alembic commands ###
项目:Albireo    作者:lordfriend    | 项目源码 | 文件源码
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('announce',
    sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
    sa.Column('url', sa.TEXT(), nullable=True),
    sa.Column('image_url', sa.TEXT(), nullable=True),
    sa.Column('position', sa.Integer(), nullable=False),
    sa.Column('sort_order', sa.Integer(), nullable=True),
    sa.Column('start_time', sa.TIMESTAMP(), nullable=False),
    sa.Column('end_time', sa.TIMESTAMP(), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    # ### end Alembic commands ###
项目:Flask_Blog    作者:sugarguo    | 项目源码 | 文件源码
def add_column(cls, operations, table_name, column, schema=None):
        """Issue an "add column" instruction using the current
        migration context.

        e.g.::

            from alembic import op
            from sqlalchemy import Column, String

            op.add_column('organization',
                Column('name', String())
            )

        The provided :class:`~sqlalchemy.schema.Column` object can also
        specify a :class:`~sqlalchemy.schema.ForeignKey`, referencing
        a remote table name.  Alembic will automatically generate a stub
        "referenced" table and emit a second ALTER statement in order
        to add the constraint separately::

            from alembic import op
            from sqlalchemy import Column, INTEGER, ForeignKey

            op.add_column('organization',
                Column('account_id', INTEGER, ForeignKey('accounts.id'))
            )

        Note that this statement uses the :class:`~sqlalchemy.schema.Column`
        construct as is from the SQLAlchemy library.  In particular,
        default values to be created on the database side are
        specified using the ``server_default`` parameter, and not
        ``default`` which only specifies Python-side defaults::

            from alembic import op
            from sqlalchemy import Column, TIMESTAMP, func

            # specify "DEFAULT NOW" along with the column add
            op.add_column('account',
                Column('timestamp', TIMESTAMP, server_default=func.now())
            )

        :param table_name: String name of the parent table.
        :param column: a :class:`sqlalchemy.schema.Column` object
         representing the new column.
        :param schema: Optional schema name to operate within.  To control
         quoting of the schema outside of the default behavior, use
         the SQLAlchemy construct
         :class:`~sqlalchemy.sql.elements.quoted_name`.

         .. versionadded:: 0.7.0 'schema' can now accept a
            :class:`~sqlalchemy.sql.elements.quoted_name` construct.


        """

        op = cls(table_name, column, schema=schema)
        return operations.invoke(op)
项目:flasky    作者:RoseOu    | 项目源码 | 文件源码
def add_column(self, table_name, column, schema=None):
        """Issue an "add column" instruction using the current
        migration context.

        e.g.::

            from alembic import op
            from sqlalchemy import Column, String

            op.add_column('organization',
                Column('name', String())
            )

        The provided :class:`~sqlalchemy.schema.Column` object can also
        specify a :class:`~sqlalchemy.schema.ForeignKey`, referencing
        a remote table name.  Alembic will automatically generate a stub
        "referenced" table and emit a second ALTER statement in order
        to add the constraint separately::

            from alembic import op
            from sqlalchemy import Column, INTEGER, ForeignKey

            op.add_column('organization',
                Column('account_id', INTEGER, ForeignKey('accounts.id'))
            )

        Note that this statement uses the :class:`~sqlalchemy.schema.Column`
        construct as is from the SQLAlchemy library.  In particular,
        default values to be created on the database side are
        specified using the ``server_default`` parameter, and not
        ``default`` which only specifies Python-side defaults::

            from alembic import op
            from sqlalchemy import Column, TIMESTAMP, func

            # specify "DEFAULT NOW" along with the column add
            op.add_column('account',
                Column('timestamp', TIMESTAMP, server_default=func.now())
            )

        :param table_name: String name of the parent table.
        :param column: a :class:`sqlalchemy.schema.Column` object
         representing the new column.
        :param schema: Optional schema name to operate within.

         .. versionadded:: 0.4.0

        """

        t = self._table(table_name, column, schema=schema)
        self.impl.add_column(
            table_name,
            column,
            schema=schema
        )
        for constraint in t.constraints:
            if not isinstance(constraint, sa_schema.PrimaryKeyConstraint):
                self.impl.add_constraint(constraint)
项目:chihu    作者:yelongyu    | 项目源码 | 文件源码
def add_column(cls, operations, table_name, column, schema=None):
        """Issue an "add column" instruction using the current
        migration context.

        e.g.::

            from alembic import op
            from sqlalchemy import Column, String

            op.add_column('organization',
                Column('name', String())
            )

        The provided :class:`~sqlalchemy.schema.Column` object can also
        specify a :class:`~sqlalchemy.schema.ForeignKey`, referencing
        a remote table name.  Alembic will automatically generate a stub
        "referenced" table and emit a second ALTER statement in order
        to add the constraint separately::

            from alembic import op
            from sqlalchemy import Column, INTEGER, ForeignKey

            op.add_column('organization',
                Column('account_id', INTEGER, ForeignKey('accounts.id'))
            )

        Note that this statement uses the :class:`~sqlalchemy.schema.Column`
        construct as is from the SQLAlchemy library.  In particular,
        default values to be created on the database side are
        specified using the ``server_default`` parameter, and not
        ``default`` which only specifies Python-side defaults::

            from alembic import op
            from sqlalchemy import Column, TIMESTAMP, func

            # specify "DEFAULT NOW" along with the column add
            op.add_column('account',
                Column('timestamp', TIMESTAMP, server_default=func.now())
            )

        :param table_name: String name of the parent table.
        :param column: a :class:`sqlalchemy.schema.Column` object
         representing the new column.
        :param schema: Optional schema name to operate within.  To control
         quoting of the schema outside of the default behavior, use
         the SQLAlchemy construct
         :class:`~sqlalchemy.sql.elements.quoted_name`.

         .. versionadded:: 0.7.0 'schema' can now accept a
            :class:`~sqlalchemy.sql.elements.quoted_name` construct.


        """

        op = cls(table_name, column, schema=schema)
        return operations.invoke(op)
项目:ShelbySearch    作者:Agentscreech    | 项目源码 | 文件源码
def add_column(cls, operations, table_name, column, schema=None):
        """Issue an "add column" instruction using the current
        migration context.

        e.g.::

            from alembic import op
            from sqlalchemy import Column, String

            op.add_column('organization',
                Column('name', String())
            )

        The provided :class:`~sqlalchemy.schema.Column` object can also
        specify a :class:`~sqlalchemy.schema.ForeignKey`, referencing
        a remote table name.  Alembic will automatically generate a stub
        "referenced" table and emit a second ALTER statement in order
        to add the constraint separately::

            from alembic import op
            from sqlalchemy import Column, INTEGER, ForeignKey

            op.add_column('organization',
                Column('account_id', INTEGER, ForeignKey('accounts.id'))
            )

        Note that this statement uses the :class:`~sqlalchemy.schema.Column`
        construct as is from the SQLAlchemy library.  In particular,
        default values to be created on the database side are
        specified using the ``server_default`` parameter, and not
        ``default`` which only specifies Python-side defaults::

            from alembic import op
            from sqlalchemy import Column, TIMESTAMP, func

            # specify "DEFAULT NOW" along with the column add
            op.add_column('account',
                Column('timestamp', TIMESTAMP, server_default=func.now())
            )

        :param table_name: String name of the parent table.
        :param column: a :class:`sqlalchemy.schema.Column` object
         representing the new column.
        :param schema: Optional schema name to operate within.  To control
         quoting of the schema outside of the default behavior, use
         the SQLAlchemy construct
         :class:`~sqlalchemy.sql.elements.quoted_name`.

         .. versionadded:: 0.7.0 'schema' can now accept a
            :class:`~sqlalchemy.sql.elements.quoted_name` construct.


        """

        op = cls(table_name, column, schema=schema)
        return operations.invoke(op)
项目:pyetje    作者:rorlika    | 项目源码 | 文件源码
def add_column(self, table_name, column, schema=None):
        """Issue an "add column" instruction using the current
        migration context.

        e.g.::

            from alembic import op
            from sqlalchemy import Column, String

            op.add_column('organization',
                Column('name', String())
            )

        The provided :class:`~sqlalchemy.schema.Column` object can also
        specify a :class:`~sqlalchemy.schema.ForeignKey`, referencing
        a remote table name.  Alembic will automatically generate a stub
        "referenced" table and emit a second ALTER statement in order
        to add the constraint separately::

            from alembic import op
            from sqlalchemy import Column, INTEGER, ForeignKey

            op.add_column('organization',
                Column('account_id', INTEGER, ForeignKey('accounts.id'))
            )

        Note that this statement uses the :class:`~sqlalchemy.schema.Column`
        construct as is from the SQLAlchemy library.  In particular,
        default values to be created on the database side are
        specified using the ``server_default`` parameter, and not
        ``default`` which only specifies Python-side defaults::

            from alembic import op
            from sqlalchemy import Column, TIMESTAMP, func

            # specify "DEFAULT NOW" along with the column add
            op.add_column('account',
                Column('timestamp', TIMESTAMP, server_default=func.now())
            )

        :param table_name: String name of the parent table.
        :param column: a :class:`sqlalchemy.schema.Column` object
         representing the new column.
        :param schema: Optional schema name to operate within.

         .. versionadded:: 0.4.0

        """

        t = self._table(table_name, column, schema=schema)
        self.impl.add_column(
            table_name,
            column,
            schema=schema
        )
        for constraint in t.constraints:
            if not isinstance(constraint, sa_schema.PrimaryKeyConstraint):
                self.impl.add_constraint(constraint)
项目:pyetje    作者:rorlika    | 项目源码 | 文件源码
def create_table(self, name, *columns, **kw):
        """Issue a "create table" instruction using the current migration context.

        This directive receives an argument list similar to that of the
        traditional :class:`sqlalchemy.schema.Table` construct, but without the
        metadata::

            from sqlalchemy import INTEGER, VARCHAR, NVARCHAR, Column
            from alembic import op

            op.create_table(
                'account',
                Column('id', INTEGER, primary_key=True),
                Column('name', VARCHAR(50), nullable=False),
                Column('description', NVARCHAR(200))
                Column('timestamp', TIMESTAMP, server_default=func.now())
            )

        Note that :meth:`.create_table` accepts :class:`~sqlalchemy.schema.Column`
        constructs directly from the SQLAlchemy library.  In particular,
        default values to be created on the database side are
        specified using the ``server_default`` parameter, and not
        ``default`` which only specifies Python-side defaults::

            from alembic import op
            from sqlalchemy import Column, TIMESTAMP, func

            # specify "DEFAULT NOW" along with the "timestamp" column
            op.create_table('account',
                Column('id', INTEGER, primary_key=True),
                Column('timestamp', TIMESTAMP, server_default=func.now())
            )

        :param name: Name of the table
        :param \*columns: collection of :class:`~sqlalchemy.schema.Column`
         objects within
         the table, as well as optional :class:`~sqlalchemy.schema.Constraint`
         objects
         and :class:`~.sqlalchemy.schema.Index` objects.
        :param schema: Optional schema name to operate within.
        :param \**kw: Other keyword arguments are passed to the underlying
         :class:`sqlalchemy.schema.Table` object created for the command.

        """
        self.impl.create_table(
            self._table(name, *columns, **kw)
        )
项目:Price-Comparator    作者:Thejas-1    | 项目源码 | 文件源码
def add_column(cls, operations, table_name, column, schema=None):
        """Issue an "add column" instruction using the current
        migration context.

        e.g.::

            from alembic import op
            from sqlalchemy import Column, String

            op.add_column('organization',
                Column('name', String())
            )

        The provided :class:`~sqlalchemy.schema.Column` object can also
        specify a :class:`~sqlalchemy.schema.ForeignKey`, referencing
        a remote table name.  Alembic will automatically generate a stub
        "referenced" table and emit a second ALTER statement in order
        to add the constraint separately::

            from alembic import op
            from sqlalchemy import Column, INTEGER, ForeignKey

            op.add_column('organization',
                Column('account_id', INTEGER, ForeignKey('accounts.id'))
            )

        Note that this statement uses the :class:`~sqlalchemy.schema.Column`
        construct as is from the SQLAlchemy library.  In particular,
        default values to be created on the database side are
        specified using the ``server_default`` parameter, and not
        ``default`` which only specifies Python-side defaults::

            from alembic import op
            from sqlalchemy import Column, TIMESTAMP, func

            # specify "DEFAULT NOW" along with the column add
            op.add_column('account',
                Column('timestamp', TIMESTAMP, server_default=func.now())
            )

        :param table_name: String name of the parent table.
        :param column: a :class:`sqlalchemy.schema.Column` object
         representing the new column.
        :param schema: Optional schema name to operate within.  To control
         quoting of the schema outside of the default behavior, use
         the SQLAlchemy construct
         :class:`~sqlalchemy.sql.elements.quoted_name`.

         .. versionadded:: 0.7.0 'schema' can now accept a
            :class:`~sqlalchemy.sql.elements.quoted_name` construct.


        """

        op = cls(table_name, column, schema=schema)
        return operations.invoke(op)
项目:webapp    作者:superchilli    | 项目源码 | 文件源码
def add_column(cls, operations, table_name, column, schema=None):
        """Issue an "add column" instruction using the current
        migration context.

        e.g.::

            from alembic import op
            from sqlalchemy import Column, String

            op.add_column('organization',
                Column('name', String())
            )

        The provided :class:`~sqlalchemy.schema.Column` object can also
        specify a :class:`~sqlalchemy.schema.ForeignKey`, referencing
        a remote table name.  Alembic will automatically generate a stub
        "referenced" table and emit a second ALTER statement in order
        to add the constraint separately::

            from alembic import op
            from sqlalchemy import Column, INTEGER, ForeignKey

            op.add_column('organization',
                Column('account_id', INTEGER, ForeignKey('accounts.id'))
            )

        Note that this statement uses the :class:`~sqlalchemy.schema.Column`
        construct as is from the SQLAlchemy library.  In particular,
        default values to be created on the database side are
        specified using the ``server_default`` parameter, and not
        ``default`` which only specifies Python-side defaults::

            from alembic import op
            from sqlalchemy import Column, TIMESTAMP, func

            # specify "DEFAULT NOW" along with the column add
            op.add_column('account',
                Column('timestamp', TIMESTAMP, server_default=func.now())
            )

        :param table_name: String name of the parent table.
        :param column: a :class:`sqlalchemy.schema.Column` object
         representing the new column.
        :param schema: Optional schema name to operate within.  To control
         quoting of the schema outside of the default behavior, use
         the SQLAlchemy construct
         :class:`~sqlalchemy.sql.elements.quoted_name`.

         .. versionadded:: 0.7.0 'schema' can now accept a
            :class:`~sqlalchemy.sql.elements.quoted_name` construct.


        """

        op = cls(table_name, column, schema=schema)
        return operations.invoke(op)
项目:QualquerMerdaAPI    作者:tiagovizoto    | 项目源码 | 文件源码
def add_column(cls, operations, table_name, column, schema=None):
        """Issue an "add column" instruction using the current
        migration context.

        e.g.::

            from alembic import op
            from sqlalchemy import Column, String

            op.add_column('organization',
                Column('name', String())
            )

        The provided :class:`~sqlalchemy.schema.Column` object can also
        specify a :class:`~sqlalchemy.schema.ForeignKey`, referencing
        a remote table name.  Alembic will automatically generate a stub
        "referenced" table and emit a second ALTER statement in order
        to add the constraint separately::

            from alembic import op
            from sqlalchemy import Column, INTEGER, ForeignKey

            op.add_column('organization',
                Column('account_id', INTEGER, ForeignKey('accounts.id'))
            )

        Note that this statement uses the :class:`~sqlalchemy.schema.Column`
        construct as is from the SQLAlchemy library.  In particular,
        default values to be created on the database side are
        specified using the ``server_default`` parameter, and not
        ``default`` which only specifies Python-side defaults::

            from alembic import op
            from sqlalchemy import Column, TIMESTAMP, func

            # specify "DEFAULT NOW" along with the column add
            op.add_column('account',
                Column('timestamp', TIMESTAMP, server_default=func.now())
            )

        :param table_name: String name of the parent table.
        :param column: a :class:`sqlalchemy.schema.Column` object
         representing the new column.
        :param schema: Optional schema name to operate within.  To control
         quoting of the schema outside of the default behavior, use
         the SQLAlchemy construct
         :class:`~sqlalchemy.sql.elements.quoted_name`.

         .. versionadded:: 0.7.0 'schema' can now accept a
            :class:`~sqlalchemy.sql.elements.quoted_name` construct.


        """

        op = cls(table_name, column, schema=schema)
        return operations.invoke(op)
项目:gardenbot    作者:GoestaO    | 项目源码 | 文件源码
def add_column(cls, operations, table_name, column, schema=None):
        """Issue an "add column" instruction using the current
        migration context.

        e.g.::

            from alembic import op
            from sqlalchemy import Column, String

            op.add_column('organization',
                Column('name', String())
            )

        The provided :class:`~sqlalchemy.schema.Column` object can also
        specify a :class:`~sqlalchemy.schema.ForeignKey`, referencing
        a remote table name.  Alembic will automatically generate a stub
        "referenced" table and emit a second ALTER statement in order
        to add the constraint separately::

            from alembic import op
            from sqlalchemy import Column, INTEGER, ForeignKey

            op.add_column('organization',
                Column('account_id', INTEGER, ForeignKey('accounts.id'))
            )

        Note that this statement uses the :class:`~sqlalchemy.schema.Column`
        construct as is from the SQLAlchemy library.  In particular,
        default values to be created on the database side are
        specified using the ``server_default`` parameter, and not
        ``default`` which only specifies Python-side defaults::

            from alembic import op
            from sqlalchemy import Column, TIMESTAMP, func

            # specify "DEFAULT NOW" along with the column add
            op.add_column('account',
                Column('timestamp', TIMESTAMP, server_default=func.now())
            )

        :param table_name: String name of the parent table.
        :param column: a :class:`sqlalchemy.schema.Column` object
         representing the new column.
        :param schema: Optional schema name to operate within.  To control
         quoting of the schema outside of the default behavior, use
         the SQLAlchemy construct
         :class:`~sqlalchemy.sql.elements.quoted_name`.

         .. versionadded:: 0.7.0 'schema' can now accept a
            :class:`~sqlalchemy.sql.elements.quoted_name` construct.


        """

        op = cls(table_name, column, schema=schema)
        return operations.invoke(op)
项目:flask-zhenai-mongo-echarts    作者:Fretice    | 项目源码 | 文件源码
def add_column(cls, operations, table_name, column, schema=None):
        """Issue an "add column" instruction using the current
        migration context.

        e.g.::

            from alembic import op
            from sqlalchemy import Column, String

            op.add_column('organization',
                Column('name', String())
            )

        The provided :class:`~sqlalchemy.schema.Column` object can also
        specify a :class:`~sqlalchemy.schema.ForeignKey`, referencing
        a remote table name.  Alembic will automatically generate a stub
        "referenced" table and emit a second ALTER statement in order
        to add the constraint separately::

            from alembic import op
            from sqlalchemy import Column, INTEGER, ForeignKey

            op.add_column('organization',
                Column('account_id', INTEGER, ForeignKey('accounts.id'))
            )

        Note that this statement uses the :class:`~sqlalchemy.schema.Column`
        construct as is from the SQLAlchemy library.  In particular,
        default values to be created on the database side are
        specified using the ``server_default`` parameter, and not
        ``default`` which only specifies Python-side defaults::

            from alembic import op
            from sqlalchemy import Column, TIMESTAMP, func

            # specify "DEFAULT NOW" along with the column add
            op.add_column('account',
                Column('timestamp', TIMESTAMP, server_default=func.now())
            )

        :param table_name: String name of the parent table.
        :param column: a :class:`sqlalchemy.schema.Column` object
         representing the new column.
        :param schema: Optional schema name to operate within.  To control
         quoting of the schema outside of the default behavior, use
         the SQLAlchemy construct
         :class:`~sqlalchemy.sql.elements.quoted_name`.

         .. versionadded:: 0.7.0 'schema' can now accept a
            :class:`~sqlalchemy.sql.elements.quoted_name` construct.


        """

        op = cls(table_name, column, schema=schema)
        return operations.invoke(op)
项目:ngx_status    作者:YoYoAdorkable    | 项目源码 | 文件源码
def add_column(cls, operations, table_name, column, schema=None):
        """Issue an "add column" instruction using the current
        migration context.

        e.g.::

            from alembic import op
            from sqlalchemy import Column, String

            op.add_column('organization',
                Column('name', String())
            )

        The provided :class:`~sqlalchemy.schema.Column` object can also
        specify a :class:`~sqlalchemy.schema.ForeignKey`, referencing
        a remote table name.  Alembic will automatically generate a stub
        "referenced" table and emit a second ALTER statement in order
        to add the constraint separately::

            from alembic import op
            from sqlalchemy import Column, INTEGER, ForeignKey

            op.add_column('organization',
                Column('account_id', INTEGER, ForeignKey('accounts.id'))
            )

        Note that this statement uses the :class:`~sqlalchemy.schema.Column`
        construct as is from the SQLAlchemy library.  In particular,
        default values to be created on the database side are
        specified using the ``server_default`` parameter, and not
        ``default`` which only specifies Python-side defaults::

            from alembic import op
            from sqlalchemy import Column, TIMESTAMP, func

            # specify "DEFAULT NOW" along with the column add
            op.add_column('account',
                Column('timestamp', TIMESTAMP, server_default=func.now())
            )

        :param table_name: String name of the parent table.
        :param column: a :class:`sqlalchemy.schema.Column` object
         representing the new column.
        :param schema: Optional schema name to operate within.  To control
         quoting of the schema outside of the default behavior, use
         the SQLAlchemy construct
         :class:`~sqlalchemy.sql.elements.quoted_name`.

         .. versionadded:: 0.7.0 'schema' can now accept a
            :class:`~sqlalchemy.sql.elements.quoted_name` construct.


        """

        op = cls(table_name, column, schema=schema)
        return operations.invoke(op)