本文整理汇总了Python中sqlalchemy.types.SmallInteger方法的典型用法代码示例。如果您正苦于以下问题:Python types.SmallInteger方法的具体用法?Python types.SmallInteger怎么用?Python types.SmallInteger使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sqlalchemy.types
的用法示例。
在下文中一共展示了types.SmallInteger方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _integer_compare
# 需要导入模块: from sqlalchemy import types [as 别名]
# 或者: from sqlalchemy.types import SmallInteger [as 别名]
def _integer_compare(t1, t2):
t1_small_or_big = (
'S' if isinstance(t1, sqltypes.SmallInteger)
else 'B' if isinstance(t1, sqltypes.BigInteger) else 'I'
)
t2_small_or_big = (
'S' if isinstance(t2, sqltypes.SmallInteger)
else 'B' if isinstance(t2, sqltypes.BigInteger) else 'I'
)
return t1_small_or_big != t2_small_or_big
示例2: test_sql_alchemy_subclass_column_types
# 需要导入模块: from sqlalchemy import types [as 别名]
# 或者: from sqlalchemy.types import SmallInteger [as 别名]
def test_sql_alchemy_subclass_column_types():
class F(FilterSet):
ALLOWED_FILTERS = {types.Integer: ['eq', 'gt']}
class Meta:
abstract = True
class MyNVARCHAR(types.NVARCHAR):
pass
class TestModel(Base):
__tablename__ = 'test'
id = Column(types.SmallInteger, primary_key=True, autoincrement=True)
text = Column(MyNVARCHAR)
class TestFilter(F):
EXTRA_ALLOWED_FILTERS = {types.String: ['eq']}
class Meta:
model = TestModel
fields = {'id': [...], 'text': [...]}
filter_fields = set(TestFilter._meta.fields)
ok = {'id', 'id_gt', 'text', 'text_is_null', 'and', 'not', 'or'}
assert filter_fields == ok
示例3: test_should_small_integer_convert_int
# 需要导入模块: from sqlalchemy import types [as 别名]
# 或者: from sqlalchemy.types import SmallInteger [as 别名]
def test_should_small_integer_convert_int():
assert get_field(types.SmallInteger()).type == graphene.Int
示例4: test_numeric
# 需要导入模块: from sqlalchemy import types [as 别名]
# 或者: from sqlalchemy.types import SmallInteger [as 别名]
def test_numeric(self):
"Exercise type specification and options for numeric types."
columns = [
# column type, args, kwargs, expected ddl
(types.NUMERIC, [], {}, "NUMERIC"),
(types.NUMERIC, [None], {}, "NUMERIC"),
(types.NUMERIC, [12, 4], {}, "NUMERIC(12, 4)"),
(types.Float, [], {}, "FLOAT"),
(types.Float, [None], {}, "FLOAT"),
(types.Float, [12], {}, "FLOAT(12)"),
(mssql.MSReal, [], {}, "REAL"),
(types.Integer, [], {}, "INTEGER"),
(types.BigInteger, [], {}, "BIGINT"),
(mssql.MSTinyInteger, [], {}, "TINYINT"),
(types.SmallInteger, [], {}, "SMALLINT"),
]
metadata = MetaData()
table_args = ["test_mssql_numeric", metadata]
for index, spec in enumerate(columns):
type_, args, kw, res = spec
table_args.append(
Column("c%s" % index, type_(*args, **kw), nullable=None)
)
numeric_table = Table(*table_args)
dialect = mssql.dialect()
gen = dialect.ddl_compiler(dialect, schema.CreateTable(numeric_table))
for col in numeric_table.c:
index = int(col.name[1:])
testing.eq_(
gen.get_column_specification(col),
"%s %s" % (col.name, columns[index][3]),
)
self.assert_(repr(col))
示例5: __init__
# 需要导入模块: from sqlalchemy import types [as 别名]
# 或者: from sqlalchemy.types import SmallInteger [as 别名]
def __init__(self):
self._types = {
# Django internal type => SQLAlchemy type
'ArrayField': SA_ARRAY,
'AutoField': sa_types.Integer,
'BigAutoField': sa_types.BigInteger,
'BigIntegerField': sa_types.BigInteger,
'BooleanField': sa_types.Boolean,
'CharField': sa_types.String,
'DateField': sa_types.Date,
'DateTimeField': sa_types.DateTime,
'DecimalField': sa_types.Numeric,
'DurationField': sa_types.Interval,
'FileField': sa_types.String,
'FilePathField': sa_types.String,
'FloatField': sa_types.Float,
'GenericIPAddressField': sa_types.String,
'IntegerField': sa_types.Integer,
'JSONField': SA_JSONB,
'NullBooleanField': sa_types.Boolean,
'PointField': Geometry,
'PositiveIntegerField': sa_types.Integer,
'PositiveSmallIntegerField': sa_types.SmallInteger,
'SlugField': sa_types.String,
'SmallIntegerField': sa_types.SmallInteger,
'TextField': sa_types.Text,
'TimeField': sa_types.Time,
'UUIDField': SA_UUID,
# TODO: Add missing GIS fields
}