本文整理汇总了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