本文整理汇总了Python中sqlalchemy.databases.mssql.dialect函数的典型用法代码示例。如果您正苦于以下问题:Python dialect函数的具体用法?Python dialect怎么用?Python dialect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dialect函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_dates
def test_dates(self):
"Exercise type specification for date types."
columns = [
# column type, args, kwargs, expected ddl
(mssql.MSDateTime, [], {}, "DATETIME", None),
(types.DATE, [], {}, "DATE", None),
(types.Date, [], {}, "DATE", None),
(types.Date, [], {}, "DATETIME", MS_2005_VERSION),
(mssql.MSDate, [], {}, "DATE", None),
(mssql.MSDate, [], {}, "DATETIME", MS_2005_VERSION),
(types.TIME, [], {}, "TIME", None),
(types.Time, [], {}, "TIME", None),
(mssql.MSTime, [], {}, "TIME", None),
(mssql.MSTime, [1], {}, "TIME(1)", None),
(types.Time, [], {}, "DATETIME", MS_2005_VERSION),
(mssql.MSTime, [], {}, "TIME", None),
(mssql.MSSmallDateTime, [], {}, "SMALLDATETIME", None),
(mssql.MSDateTimeOffset, [], {}, "DATETIMEOFFSET", None),
(mssql.MSDateTimeOffset, [1], {}, "DATETIMEOFFSET(1)", None),
(mssql.MSDateTime2, [], {}, "DATETIME2", None),
(mssql.MSDateTime2, [0], {}, "DATETIME2(0)", None),
(mssql.MSDateTime2, [1], {}, "DATETIME2(1)", None),
(mssql.MSTime, [0], {}, "TIME(0)", None),
(mssql.MSDateTimeOffset, [0], {}, "DATETIMEOFFSET(0)", None),
]
metadata = MetaData()
table_args = ["test_mssql_dates", metadata]
for index, spec in enumerate(columns):
type_, args, kw, res, server_version = spec
table_args.append(
Column("c%s" % index, type_(*args, **kw), nullable=None)
)
date_table = Table(*table_args)
dialect = mssql.dialect()
dialect.server_version_info = MS_2008_VERSION
ms_2005_dialect = mssql.dialect()
ms_2005_dialect.server_version_info = MS_2005_VERSION
gen = dialect.ddl_compiler(dialect, schema.CreateTable(date_table))
gen2005 = ms_2005_dialect.ddl_compiler(
ms_2005_dialect, schema.CreateTable(date_table)
)
for col in date_table.c:
index = int(col.name[1:])
server_version = columns[index][4]
if not server_version:
testing.eq_(
gen.get_column_specification(col),
"%s %s" % (col.name, columns[index][3]),
)
else:
testing.eq_(
gen2005.get_column_specification(col),
"%s %s" % (col.name, columns[index][3]),
)
self.assert_(repr(col))
开发者ID:vrajmohan,项目名称:sqlalchemy,代码行数:60,代码来源:test_types.py
示例2: _assert_sql
def _assert_sql(self, element, legacy_sql, modern_sql=None):
dialect = mssql.dialect(legacy_schema_aliasing=True)
self.assert_compile(element, legacy_sql, dialect=dialect)
dialect = mssql.dialect()
self.assert_compile(element, modern_sql or "foob", dialect=dialect)
开发者ID:monetate,项目名称:sqlalchemy,代码行数:7,代码来源:test_query.py
示例3: test_numeric
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))
开发者ID:GitHublong,项目名称:sqlalchemy,代码行数:32,代码来源:test_types.py
示例4: test_binary
def test_binary(self):
"Exercise type specification for binary types."
columns = [
# column type, args, kwargs, expected ddl
(mssql.MSBinary, [], {}, "BINARY"),
(mssql.MSBinary, [10], {}, "BINARY(10)"),
(types.BINARY, [], {}, "BINARY"),
(types.BINARY, [10], {}, "BINARY(10)"),
(mssql.MSVarBinary, [], {}, "VARBINARY(max)"),
(mssql.MSVarBinary, [10], {}, "VARBINARY(10)"),
(types.VARBINARY, [10], {}, "VARBINARY(10)"),
(types.VARBINARY, [], {}, "VARBINARY(max)"),
(mssql.MSImage, [], {}, "IMAGE"),
(mssql.IMAGE, [], {}, "IMAGE"),
(types.LargeBinary, [], {}, "IMAGE"),
]
metadata = MetaData()
table_args = ["test_mssql_binary", metadata]
for index, spec in enumerate(columns):
type_, args, kw, res = spec
table_args.append(
Column("c%s" % index, type_(*args, **kw), nullable=None)
)
binary_table = Table(*table_args)
dialect = mssql.dialect()
gen = dialect.ddl_compiler(dialect, schema.CreateTable(binary_table))
for col in binary_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))
开发者ID:vrajmohan,项目名称:sqlalchemy,代码行数:35,代码来源:test_types.py
示例5: test_char
def test_char(self):
"""Exercise COLLATE-ish options on string types."""
columns = [
(mssql.MSChar, [], {},
'CHAR'),
(mssql.MSChar, [1], {},
'CHAR(1)'),
(mssql.MSChar, [1], {'collation': 'Latin1_General_CI_AS'},
'CHAR(1) COLLATE Latin1_General_CI_AS'),
(mssql.MSNChar, [], {},
'NCHAR'),
(mssql.MSNChar, [1], {},
'NCHAR(1)'),
(mssql.MSNChar, [1], {'collation': 'Latin1_General_CI_AS'},
'NCHAR(1) COLLATE Latin1_General_CI_AS'),
(mssql.MSString, [], {},
'VARCHAR(max)'),
(mssql.MSString, [1], {},
'VARCHAR(1)'),
(mssql.MSString, [1], {'collation': 'Latin1_General_CI_AS'},
'VARCHAR(1) COLLATE Latin1_General_CI_AS'),
(mssql.MSNVarchar, [], {},
'NVARCHAR(max)'),
(mssql.MSNVarchar, [1], {},
'NVARCHAR(1)'),
(mssql.MSNVarchar, [1], {'collation': 'Latin1_General_CI_AS'},
'NVARCHAR(1) COLLATE Latin1_General_CI_AS'),
(mssql.MSText, [], {},
'TEXT'),
(mssql.MSText, [], {'collation': 'Latin1_General_CI_AS'},
'TEXT COLLATE Latin1_General_CI_AS'),
(mssql.MSNText, [], {},
'NTEXT'),
(mssql.MSNText, [], {'collation': 'Latin1_General_CI_AS'},
'NTEXT COLLATE Latin1_General_CI_AS'),
]
metadata = MetaData()
table_args = ['test_mssql_charset', metadata]
for index, spec in enumerate(columns):
type_, args, kw, res = spec
table_args.append(
Column('c%s' % index, type_(*args, **kw), nullable=None))
charset_table = Table(*table_args)
dialect = mssql.dialect()
gen = dialect.ddl_compiler(dialect, schema.CreateTable(charset_table))
for col in charset_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))
开发者ID:MyExperience,项目名称:HealAssist,代码行数:60,代码来源:test_types.py
示例6: test_boolean
def test_boolean(self):
"Exercise type specification for boolean type."
columns = [
# column type, args, kwargs, expected ddl
(Boolean, [], {},
'BIT'),
]
metadata = MetaData()
table_args = ['test_mssql_boolean', metadata]
for index, spec in enumerate(columns):
type_, args, kw, res = spec
table_args.append(
Column('c%s' % index, type_(*args, **kw), nullable=None))
boolean_table = Table(*table_args)
dialect = mssql.dialect()
gen = dialect.ddl_compiler(dialect, schema.CreateTable(boolean_table))
for col in boolean_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))
开发者ID:MyExperience,项目名称:HealAssist,代码行数:26,代码来源:test_types.py
示例7: _assert_sql
def _assert_sql(self, element, legacy_sql, modern_sql=None):
dialect = mssql.dialect()
with assertions.expect_warnings(
"legacy_schema_aliasing flag is defaulted to True.*"):
self.assert_compile(
element,
legacy_sql,
dialect=dialect
)
dialect = mssql.dialect(legacy_schema_aliasing=False)
self.assert_compile(
element,
modern_sql or "foob",
dialect=dialect
)
开发者ID:DeepakAlevoor,项目名称:sqlalchemy,代码行数:17,代码来源:test_query.py
示例8: test_info_unicode_cast_no_2000
def test_info_unicode_cast_no_2000(self):
dialect = mssql.dialect()
dialect.server_version_info = base.MS_2000_VERSION
stmt = tables.c.table_name == 'somename'
self.assert_compile(
stmt,
"[INFORMATION_SCHEMA].[TABLES].[TABLE_NAME] = :table_name_1",
dialect=dialect
)
开发者ID:anti-social,项目名称:sqlalchemy,代码行数:9,代码来源:test_reflection.py
示例9: test_info_unicode_cast
def test_info_unicode_cast(self):
dialect = mssql.dialect()
dialect.server_version_info = base.MS_2005_VERSION
stmt = tables.c.table_name == 'somename'
self.assert_compile(
stmt,
"[TABLES_1].[TABLE_NAME] = CAST(:table_name_1 AS NVARCHAR(max))",
dialect=dialect
)
开发者ID:Attsun1031,项目名称:sqlalchemy,代码行数:9,代码来源:test_reflection.py
示例10: test_large_type_deprecation
def test_large_type_deprecation(self):
d1 = mssql.dialect(deprecate_large_types=True)
d2 = mssql.dialect(deprecate_large_types=False)
d3 = mssql.dialect()
d3.server_version_info = (11, 0)
d3._setup_version_attributes()
d4 = mssql.dialect()
d4.server_version_info = (10, 0)
d4._setup_version_attributes()
for dialect in (d1, d3):
eq_(str(Text().compile(dialect=dialect)), "VARCHAR(max)")
eq_(str(UnicodeText().compile(dialect=dialect)), "NVARCHAR(max)")
eq_(str(LargeBinary().compile(dialect=dialect)), "VARBINARY(max)")
for dialect in (d2, d4):
eq_(str(Text().compile(dialect=dialect)), "TEXT")
eq_(str(UnicodeText().compile(dialect=dialect)), "NTEXT")
eq_(str(LargeBinary().compile(dialect=dialect)), "IMAGE")
开发者ID:vrajmohan,项目名称:sqlalchemy,代码行数:19,代码来源:test_types.py
示例11: test_info_unicode_cast
def test_info_unicode_cast(self):
dialect = mssql.dialect()
dialect.server_version_info = base.MS_2005_VERSION
stmt = tables.c.table_name == "somename"
self.assert_compile(
stmt,
"[INFORMATION_SCHEMA].[TABLES].[TABLE_NAME] = "
"CAST(:table_name_1 AS NVARCHAR(max))",
dialect=dialect,
)
开发者ID:BY-jk,项目名称:sqlalchemy,代码行数:10,代码来源:test_reflection.py
示例12: test_timestamp
def test_timestamp(self):
"""Exercise TIMESTAMP column."""
dialect = mssql.dialect()
metadata = MetaData()
spec, expected = (TIMESTAMP, "TIMESTAMP")
t = Table("mssql_ts", metadata, Column("id", Integer, primary_key=True), Column("t", spec, nullable=None))
gen = dialect.ddl_compiler(dialect, schema.CreateTable(t))
testing.eq_(gen.get_column_specification(t.c.t), "t %s" % expected)
self.assert_(repr(t.c.t))
开发者ID:GitHublong,项目名称:sqlalchemy,代码行数:11,代码来源:test_types.py
示例13: test_money
def test_money(self):
"""Exercise type specification for money types."""
columns = [(mssql.MSMoney, [], {}, "MONEY"), (mssql.MSSmallMoney, [], {}, "SMALLMONEY")]
metadata = MetaData()
table_args = ["test_mssql_money", metadata]
for index, spec in enumerate(columns):
type_, args, kw, res = spec
table_args.append(Column("c%s" % index, type_(*args, **kw), nullable=None))
money_table = Table(*table_args)
dialect = mssql.dialect()
gen = dialect.ddl_compiler(dialect, schema.CreateTable(money_table))
for col in money_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))
开发者ID:GitHublong,项目名称:sqlalchemy,代码行数:16,代码来源:test_types.py
示例14: test_info_unicode_coercion
def test_info_unicode_coercion(self):
dialect = mssql.dialect()
value = CoerceUnicode().bind_processor(dialect)('a string')
assert isinstance(value, util.text_type)
开发者ID:anti-social,项目名称:sqlalchemy,代码行数:5,代码来源:test_reflection.py
示例15: setup
def setup(self):
t = Table("sometable", MetaData(), Column("pk_column", Integer), Column("test_column", String))
self.column = t.c.test_column
dialect = mssql.dialect()
self.ddl_compiler = dialect.ddl_compiler(dialect, schema.CreateTable(t))
开发者ID:hunterfu,项目名称:LuoYunCloud,代码行数:6,代码来源:test_compiler.py
示例16: _legacy_dialect
def _legacy_dialect(self):
return mssql.dialect(legacy_schema_aliasing=True)
开发者ID:monetate,项目名称:sqlalchemy,代码行数:2,代码来源:test_query.py
注:本文中的sqlalchemy.databases.mssql.dialect函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论