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


Python schema.CreateSequence方法代碼示例

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


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

示例1: test_schema_translate_map_sequence

# 需要導入模塊: from sqlalchemy import schema [as 別名]
# 或者: from sqlalchemy.schema import CreateSequence [as 別名]
def test_schema_translate_map_sequence(self):
        s1 = schema.Sequence("s1")
        s2 = schema.Sequence("s2", schema="foo")
        s3 = schema.Sequence("s3", schema="bar")

        schema_translate_map = {None: "z", "bar": None, "foo": "bat"}

        self.assert_compile(
            schema.CreateSequence(s1),
            "CREATE SEQUENCE [SCHEMA__none].s1 START WITH 1",
            schema_translate_map=schema_translate_map,
        )

        self.assert_compile(
            schema.CreateSequence(s2),
            "CREATE SEQUENCE [SCHEMA_foo].s2 START WITH 1",
            schema_translate_map=schema_translate_map,
        )

        self.assert_compile(
            schema.CreateSequence(s3),
            "CREATE SEQUENCE [SCHEMA_bar].s3 START WITH 1",
            schema_translate_map=schema_translate_map,
        ) 
開發者ID:sqlalchemy,項目名稱:sqlalchemy,代碼行數:26,代碼來源:test_compiler.py

示例2: upgrade

# 需要導入模塊: from sqlalchemy import schema [as 別名]
# 或者: from sqlalchemy.schema import CreateSequence [as 別名]
def upgrade():
    op.execute(CreateSequence(Sequence("task_id_sequence")))
    op.execute(CreateSequence(Sequence("taskset_id_sequence"))) 
開發者ID:Salamek,項目名稱:gitlab-tools,代碼行數:5,代碼來源:0bf6832fd1f2_.py

示例3: upgrade

# 需要導入模塊: from sqlalchemy import schema [as 別名]
# 或者: from sqlalchemy.schema import CreateSequence [as 別名]
def upgrade():
	# Create an auto-increment sequence for cards.id
	conn = alembic.context.get_context().bind
	meta = sqlalchemy.MetaData(bind=conn)
	meta.reflect()
	cards = meta.tables['cards']
	# This table already has a (not-previously-used) auto-increment sequence in
	# the production DB, but new DBs created from scratch via the alembic setup
	# won't have it, so check if it already exists and create if it's missing
	# to bring everything back into sync
	if not cards.c.id.server_default or 'cards_id_seq' not in cards.c.id.server_default.arg.text:
		maxid, = conn.execute(sqlalchemy.select([sqlalchemy.func.max(cards.c.id)])).first()
		if maxid is None:
			maxid = 0
		alembic.op.execute(CreateSequence(Sequence('cards_id_seq', start=maxid + 1)))
		alembic.op.alter_column("cards", "id", nullable=False, server_default=sqlalchemy.text("nextval('cards_id_seq'::regclass)"))

	# Add cards.game column
	# create it with a default but then remove the default, to set the value on
	# all existing rows, but have the column mandatory in the future
	alembic.op.drop_index("cards_name_idx")
	alembic.op.add_column('cards',
		sqlalchemy.Column('game', sqlalchemy.Integer, nullable=False, server_default='1')
	)
	alembic.op.alter_column("cards", "game", server_default=None)
	alembic.op.create_index("cards_name_idx", "cards", ["game", "filteredname"], unique=True) 
開發者ID:mrphlip,項目名稱:lrrbot,代碼行數:28,代碼來源:f63e1a13dfe5_add_game_column_to_cards.py

示例4: create_seq

# 需要導入模塊: from sqlalchemy import schema [as 別名]
# 或者: from sqlalchemy.schema import CreateSequence [as 別名]
def create_seq(seq):
    if dialect_supports_sequences():
        op.execute(CreateSequence(seq)) 
開發者ID:privacyidea,項目名稱:privacyidea,代碼行數:5,代碼來源:e360c56bcf8c_.py

示例5: downgrade

# 需要導入模塊: from sqlalchemy import schema [as 別名]
# 或者: from sqlalchemy.schema import CreateSequence [as 別名]
def downgrade():
    # Create new column 'id' and autoincrement its value
    op.execute(CreateSequence(Sequence("carbonmonoxide_id_seq")))
    op.add_column('carbonmonoxide', sa.Column(
        'id', sa.INTEGER(), nullable=False,
        server_default=sa.text("nextval('carbonmonoxide_id_seq'::regclass)")))

    # Use 'id' as the new primary key
    op.create_primary_key('carbonmonoxide_pkey', 'carbonmonoxide', ['id']) 
開發者ID:emissions-api,項目名稱:emissions-api,代碼行數:11,代碼來源:b3ae57ee07d4_drop_carbonmonoxide_id.py

示例6: _assert_create

# 需要導入模塊: from sqlalchemy import schema [as 別名]
# 或者: from sqlalchemy.schema import CreateSequence [as 別名]
def _assert_create(self, elements, generator, argument):
        self._assert_ddl(
            (schema.CreateTable, schema.CreateSequence, schema.CreateIndex),
            elements,
            generator,
            argument,
        ) 
開發者ID:sqlalchemy,項目名稱:sqlalchemy,代碼行數:9,代碼來源:test_ddlemit.py

示例7: _assert_create_w_alter

# 需要導入模塊: from sqlalchemy import schema [as 別名]
# 或者: from sqlalchemy.schema import CreateSequence [as 別名]
def _assert_create_w_alter(self, elements, generator, argument):
        self._assert_ddl(
            (schema.CreateTable, schema.CreateSequence, schema.AddConstraint),
            elements,
            generator,
            argument,
        ) 
開發者ID:sqlalchemy,項目名稱:sqlalchemy,代碼行數:9,代碼來源:test_ddlemit.py


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