python类Sequence()的实例源码

base.py 文件源码 项目:Chorus 作者: DonaldBough 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def get_column_specification(self, column, **kwargs):
        colspec = self.preparer.format_column(column) + " " + \
            self.dialect.type_compiler.process(
                column.type, type_expression=column)

        if column.table is None:
            raise exc.CompileError(
                "The Sybase dialect requires Table-bound "
                "columns in order to generate DDL")
        seq_col = column.table._autoincrement_column

        # install a IDENTITY Sequence if we have an implicit IDENTITY column
        if seq_col is column:
            sequence = isinstance(column.default, sa_schema.Sequence) \
                and column.default
            if sequence:
                start, increment = sequence.start or 1, \
                    sequence.increment or 1
            else:
                start, increment = 1, 1
            if (start, increment) == (1, 1):
                colspec += " IDENTITY"
            else:
                # TODO: need correct syntax for this
                colspec += " IDENTITY(%s,%s)" % (start, increment)
        else:
            default = self.get_column_default_string(column)
            if default is not None:
                colspec += " DEFAULT " + default

            if column.nullable is not None:
                if not column.nullable or column.primary_key:
                    colspec += " NOT NULL"
                else:
                    colspec += " NULL"

        return colspec
base.py 文件源码 项目:Hawkeye 作者: tozhengxq 项目源码 文件源码 阅读 13 收藏 0 点赞 0 评论 0
def get_column_specification(self, column, **kwargs):
        colspec = self.preparer.format_column(column) + " " + \
            self.dialect.type_compiler.process(
                column.type, type_expression=column)

        if column.table is None:
            raise exc.CompileError(
                "The Sybase dialect requires Table-bound "
                "columns in order to generate DDL")
        seq_col = column.table._autoincrement_column

        # install a IDENTITY Sequence if we have an implicit IDENTITY column
        if seq_col is column:
            sequence = isinstance(column.default, sa_schema.Sequence) \
                and column.default
            if sequence:
                start, increment = sequence.start or 1, \
                    sequence.increment or 1
            else:
                start, increment = 1, 1
            if (start, increment) == (1, 1):
                colspec += " IDENTITY"
            else:
                # TODO: need correct syntax for this
                colspec += " IDENTITY(%s,%s)" % (start, increment)
        else:
            default = self.get_column_default_string(column)
            if default is not None:
                colspec += " DEFAULT " + default

            if column.nullable is not None:
                if not column.nullable or column.primary_key:
                    colspec += " NOT NULL"
                else:
                    colspec += " NULL"

        return colspec
base.py 文件源码 项目:Alfred 作者: jkachhadia 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def get_column_specification(self, column, **kwargs):
        colspec = self.preparer.format_column(column) + " " + \
            self.dialect.type_compiler.process(
                column.type, type_expression=column)

        if column.table is None:
            raise exc.CompileError(
                "The Sybase dialect requires Table-bound "
                "columns in order to generate DDL")
        seq_col = column.table._autoincrement_column

        # install a IDENTITY Sequence if we have an implicit IDENTITY column
        if seq_col is column:
            sequence = isinstance(column.default, sa_schema.Sequence) \
                and column.default
            if sequence:
                start, increment = sequence.start or 1, \
                    sequence.increment or 1
            else:
                start, increment = 1, 1
            if (start, increment) == (1, 1):
                colspec += " IDENTITY"
            else:
                # TODO: need correct syntax for this
                colspec += " IDENTITY(%s,%s)" % (start, increment)
        else:
            default = self.get_column_default_string(column)
            if default is not None:
                colspec += " DEFAULT " + default

            if column.nullable is not None:
                if not column.nullable or column.primary_key:
                    colspec += " NOT NULL"
                else:
                    colspec += " NULL"

        return colspec
base.py 文件源码 项目:ngx_status 作者: YoYoAdorkable 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def get_column_specification(self, column, **kwargs):
        colspec = self.preparer.format_column(column) + " " + \
            self.dialect.type_compiler.process(
                column.type, type_expression=column)

        if column.table is None:
            raise exc.CompileError(
                "The Sybase dialect requires Table-bound "
                "columns in order to generate DDL")
        seq_col = column.table._autoincrement_column

        # install a IDENTITY Sequence if we have an implicit IDENTITY column
        if seq_col is column:
            sequence = isinstance(column.default, sa_schema.Sequence) \
                and column.default
            if sequence:
                start, increment = sequence.start or 1, \
                    sequence.increment or 1
            else:
                start, increment = 1, 1
            if (start, increment) == (1, 1):
                colspec += " IDENTITY"
            else:
                # TODO: need correct syntax for this
                colspec += " IDENTITY(%s,%s)" % (start, increment)
        else:
            default = self.get_column_default_string(column)
            if default is not None:
                colspec += " DEFAULT " + default

            if column.nullable is not None:
                if not column.nullable or column.primary_key:
                    colspec += " NOT NULL"
                else:
                    colspec += " NULL"

        return colspec
8648ae6436f0_initial_database.py 文件源码 项目:heroku-python-boilerplate 作者: chavli 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.execute(CreateSequence(Sequence("endpoint_log_id_seq")))
    op.execute(CreateSequence(Sequence("session_token_id_seq")))
    op.execute(CreateSequence(Sequence("system_log_id_seq")))
    op.execute(CreateSequence(Sequence("user_account_id_seq")))

    op.create_table('endpoint_log',
    sa.Column('id', sa.INTEGER(), server_default=sa.text("nextval('endpoint_log_id_seq')"), nullable=False),
    sa.Column('start_utc', postgresql.TIMESTAMP(), nullable=False),
    sa.Column('duration_ms', sa.INTEGER(), nullable=False),
    sa.Column('endpoint', sa.TEXT(), nullable=True),
    sa.Column('username', sa.TEXT(), nullable=True),
    sa.Column('method', sa.TEXT(), nullable=True),
    sa.Column('http_code', sa.TEXT(), nullable=True),
    sa.Column('error_message', sa.TEXT(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('session_token',
    sa.Column('id', sa.INTEGER(), server_default=sa.text("nextval('session_token_id_seq')"), nullable=False),
    sa.Column('user_id', sa.TEXT(), nullable=True),
    sa.Column('token', sa.TEXT(), nullable=True),
    sa.Column('created_utc', postgresql.TIMESTAMP(), server_default=sa.text('now()'), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('system_log',
    sa.Column('id', sa.INTEGER(), server_default=sa.text("nextval('system_log_id_seq')"), nullable=False),
    sa.Column('event_utc', postgresql.TIMESTAMP(), server_default=sa.text('now()'), nullable=False),
    sa.Column('level', sa.TEXT(), nullable=True),
    sa.Column('message', sa.TEXT(), nullable=True),
    sa.Column('source', sa.TEXT(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('user_account',
    sa.Column('id', sa.INTEGER(), server_default=sa.text("nextval('user_account_id_seq')"), nullable=False),
    sa.Column('user_id', sa.TEXT(), nullable=True),
    sa.Column('email', sa.TEXT(), nullable=True),
    sa.Column('secret', sa.TEXT(), nullable=True),
    sa.Column('creation_utc', postgresql.TIMESTAMP(), server_default=sa.text('now()'), nullable=True),
    sa.Column('last_updated_utc', postgresql.TIMESTAMP(), server_default=sa.text('now()'), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    # ### end Alembic commands ###


问题


面经


文章

微信
公众号

扫码关注公众号