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


Python mysql.INTEGER屬性代碼示例

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


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

示例1: upgrade

# 需要導入模塊: from sqlalchemy.dialects import mysql [as 別名]
# 或者: from sqlalchemy.dialects.mysql import INTEGER [as 別名]
def upgrade():
    # When making changes to a column that has a foreign key, we need to drop
    # and then re-add the constraint
    op.execute('DELETE FROM txn_reconciles WHERE txn_id IS NULL;')
    op.execute('LOCK TABLES txn_reconciles WRITE, transactions WRITE;')
    op.drop_constraint('fk_txn_reconciles_txn_id_transactions',
                       'txn_reconciles', type_='foreignkey')
    op.alter_column(
        'txn_reconciles',
        'txn_id',
        existing_type=mysql.INTEGER(display_width=11),
        nullable=False
    )
    op.create_foreign_key('fk_txn_reconciles_txn_id_transactions',
                          'txn_reconciles', 'transactions', ['txn_id'], ['id'])
    op.execute('UNLOCK TABLES;') 
開發者ID:jantman,項目名稱:biweeklybudget,代碼行數:18,代碼來源:5446559aecf7_txnreconcile_txn_id_not_null.py

示例2: test_mysql_column_types

# 需要導入模塊: from sqlalchemy.dialects import mysql [as 別名]
# 或者: from sqlalchemy.dialects.mysql import INTEGER [as 別名]
def test_mysql_column_types(metadata):
    Table("simple_items", metadata, Column("id", mysql.INTEGER), Column("name", mysql.VARCHAR(255)))

    assert (
        generate_code(metadata)
        == """\
# coding: utf-8
from sqlalchemy import Column, Integer, MetaData, String, Table

metadata = MetaData()


t_simple_items = Table(
    'simple_items', metadata,
    Column('id', Integer),
    Column('name', String(255))
)
"""
    ) 
開發者ID:thomaxxl,項目名稱:safrs,代碼行數:21,代碼來源:test_codegen.py

示例3: test_noconstraints_table

# 需要導入模塊: from sqlalchemy.dialects import mysql [as 別名]
# 或者: from sqlalchemy.dialects.mysql import INTEGER [as 別名]
def test_noconstraints_table(metadata):
    simple_items = Table("simple_items", metadata, Column("number", INTEGER), CheckConstraint("number > 2"))
    simple_items.indexes.add(Index("idx_number", simple_items.c.number))

    assert (
        generate_code(metadata, noconstraints=True)
        == """\
# coding: utf-8
from sqlalchemy import Column, Integer, MetaData, Table

metadata = MetaData()


t_simple_items = Table(
    'simple_items', metadata,
    Column('number', Integer, index=True)
)
"""
    ) 
開發者ID:thomaxxl,項目名稱:safrs,代碼行數:21,代碼來源:test_codegen.py

示例4: test_indexes_table

# 需要導入模塊: from sqlalchemy.dialects import mysql [as 別名]
# 或者: from sqlalchemy.dialects.mysql import INTEGER [as 別名]
def test_indexes_table(metadata):
    simple_items = Table("simple_items", metadata, Column("id", INTEGER), Column("number", INTEGER), Column("text", VARCHAR))
    simple_items.indexes.add(Index("idx_number", simple_items.c.number))
    simple_items.indexes.add(Index("idx_text_number", simple_items.c.text, simple_items.c.number, unique=True))
    simple_items.indexes.add(Index("idx_text", simple_items.c.text, unique=True))

    assert (
        generate_code(metadata)
        == """\
# coding: utf-8
from sqlalchemy import Column, Index, Integer, MetaData, String, Table

metadata = MetaData()


t_simple_items = Table(
    'simple_items', metadata,
    Column('id', Integer),
    Column('number', Integer, index=True),
    Column('text', String, unique=True),
    Index('idx_text_number', 'text', 'number', unique=True)
)
"""
    ) 
開發者ID:thomaxxl,項目名稱:safrs,代碼行數:26,代碼來源:test_codegen.py

示例5: test_no_inflect

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

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

Base = declarative_base()
metadata = Base.metadata


class SimpleItems(Base):
    __tablename__ = 'simple_items'

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

示例6: test_no_classes

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

    assert (
        generate_code(metadata, noclasses=True)
        == """\
# coding: utf-8
from sqlalchemy import Column, Integer, MetaData, Table

metadata = MetaData()


t_simple_items = Table(
    'simple_items', metadata,
    Column('id', Integer, primary_key=True)
)
"""
    ) 
開發者ID:thomaxxl,項目名稱:safrs,代碼行數:20,代碼來源:test_codegen.py

示例7: test_table_kwargs

# 需要導入模塊: from sqlalchemy.dialects import mysql [as 別名]
# 或者: from sqlalchemy.dialects.mysql import INTEGER [as 別名]
def test_table_kwargs(metadata):
    Table("simple_items", metadata, Column("id", INTEGER, primary_key=True), schema="testschema")

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

Base = declarative_base()
metadata = Base.metadata


class SimpleItem(Base):
    __tablename__ = 'simple_items'
    __table_args__ = {'schema': 'testschema'}

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

示例8: test_schema_boolean

# 需要導入模塊: from sqlalchemy.dialects import mysql [as 別名]
# 或者: from sqlalchemy.dialects.mysql import INTEGER [as 別名]
def test_schema_boolean(metadata):
    Table(
        "simple_items", metadata, Column("bool1", INTEGER), CheckConstraint("testschema.simple_items.bool1 IN (0, 1)"), schema="testschema"
    )

    assert (
        generate_code(metadata)
        == """\
# coding: utf-8
from sqlalchemy import Boolean, Column, MetaData, Table

metadata = MetaData()


t_simple_items = Table(
    'simple_items', metadata,
    Column('bool1', Boolean),
    schema='testschema'
)
"""
    ) 
開發者ID:thomaxxl,項目名稱:safrs,代碼行數:23,代碼來源:test_codegen.py

示例9: test_pk_default

# 需要導入模塊: from sqlalchemy.dialects import mysql [as 別名]
# 或者: from sqlalchemy.dialects.mysql import INTEGER [as 別名]
def test_pk_default(metadata):
    Table("simple_items", metadata, Column("id", INTEGER, primary_key=True, server_default=text("uuid_generate_v4()")))

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

Base = declarative_base()
metadata = Base.metadata


class SimpleItem(Base):
    __tablename__ = 'simple_items'

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

示例10: test_server_default_double_quotes

# 需要導入模塊: from sqlalchemy.dialects import mysql [as 別名]
# 或者: from sqlalchemy.dialects.mysql import INTEGER [as 別名]
def test_server_default_double_quotes(metadata):
    Table("simple", metadata, Column("id", INTEGER, primary_key=True, server_default=text('nextval("foo")')))

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

Base = declarative_base()
metadata = Base.metadata


class Simple(Base):
    __tablename__ = 'simple'

    id = Column(Integer, primary_key=True, server_default=text("nextval(\\"foo\\")"))
"""
    ) 
開發者ID:thomaxxl,項目名稱:safrs,代碼行數:22,代碼來源:test_codegen.py

示例11: test_pascal

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

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

Base = declarative_base()
metadata = Base.metadata


class CustomerAPIPreference(Base):
    __tablename__ = 'CustomerAPIPreference'

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

示例12: test_underscore

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

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

Base = declarative_base()
metadata = Base.metadata


class CustomerApiPreference(Base):
    __tablename__ = 'customer_api_preference'

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

示例13: test_pascal_underscore

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

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

Base = declarative_base()
metadata = Base.metadata


class CustomerAPIPreference(Base):
    __tablename__ = 'customer_API_Preference'

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

示例14: test_pascal_multiple_underscore

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

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

Base = declarative_base()
metadata = Base.metadata


class CustomerAPIPreference(Base):
    __tablename__ = 'customer_API__Preference'

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

示例15: test_metadata_column

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

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

Base = declarative_base()
metadata = Base.metadata


class Simple(Base):
    __tablename__ = 'simple'

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


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