本文整理匯總了Python中sqlalchemy.types.SMALLINT屬性的典型用法代碼示例。如果您正苦於以下問題:Python types.SMALLINT屬性的具體用法?Python types.SMALLINT怎麽用?Python types.SMALLINT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類sqlalchemy.types
的用法示例。
在下文中一共展示了types.SMALLINT屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_boolean_detection
# 需要導入模塊: from sqlalchemy import types [as 別名]
# 或者: from sqlalchemy.types import SMALLINT [as 別名]
def test_boolean_detection(metadata):
Table(
"simple_items",
metadata,
Column("bool1", INTEGER),
Column("bool2", SMALLINT),
Column("bool3", mysql.TINYINT),
CheckConstraint("simple_items.bool1 IN (0, 1)"),
CheckConstraint("simple_items.bool2 IN (0, 1)"),
CheckConstraint("simple_items.bool3 IN (0, 1)"),
)
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),
Column('bool2', Boolean),
Column('bool3', Boolean)
)
"""
)
示例2: build_metadata_blacklist
# 需要導入模塊: from sqlalchemy import types [as 別名]
# 或者: from sqlalchemy.types import SMALLINT [as 別名]
def build_metadata_blacklist(metadata=None):
if not metadata:
metadata = sa.MetaData()
sa.Table(
'hive_posts_status', metadata,
sa.Column('id', sa.Integer, primary_key=True, autoincrement=True),
sa.Column('post_id', sa.Integer, nullable=False, server_default='0'),
sa.Column('author', VARCHAR(16), nullable=False, server_default=''),
sa.Column('list_type', SMALLINT, nullable=False, server_default='0'),
sa.Column('created_at', sa.DateTime, nullable=False, server_default='1990-01-01'),
sa.UniqueConstraint('list_type', 'post_id', 'author', name='hive_posts_status_ux1'),
)
return metadata
示例3: sqltype_to_stdtype
# 需要導入模塊: from sqlalchemy import types [as 別名]
# 或者: from sqlalchemy.types import SMALLINT [as 別名]
def sqltype_to_stdtype(sqltype):
import sqlalchemy.types as sqltypes
if isinstance(sqltype, (sqltypes.VARCHAR, sqltypes.CHAR, sqltypes.TEXT, sqltypes.Enum, sqltypes.String)):
return _STRING_TYPE
if isinstance(sqltype, (sqltypes.DATETIME, sqltypes.DATE, sqltypes.TIME, sqltypes.TIMESTAMP)):
return _DATE_TYPE
if isinstance(sqltype, (sqltypes.INTEGER, sqltypes.BIGINT, sqltypes.SMALLINT, sqltypes.Integer)):
return _INTEGER_TYPE
if isinstance(sqltype, (sqltypes.REAL, sqltypes.DECIMAL, sqltypes.NUMERIC, sqltypes.FLOAT)):
return _DECIMAL_TYPE
if isinstance(sqltype, sqltypes.BOOLEAN):
return _BOOLEAN_TYPE