本文整理汇总了Python中sqlalchemy.dialects.sqlite.base.dialect函数的典型用法代码示例。如果您正苦于以下问题:Python dialect函数的具体用法?Python dialect怎么用?Python dialect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dialect函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_dialect_specific
def test_dialect_specific(self):
class AddThingy(DDLElement):
__visit_name__ = 'add_thingy'
class DropThingy(DDLElement):
__visit_name__ = 'drop_thingy'
@compiles(AddThingy, 'sqlite')
def visit_add_thingy(thingy, compiler, **kw):
return "ADD SPECIAL SL THINGY"
@compiles(AddThingy)
def visit_add_thingy(thingy, compiler, **kw):
return "ADD THINGY"
@compiles(DropThingy)
def visit_drop_thingy(thingy, compiler, **kw):
return "DROP THINGY"
self.assert_compile(AddThingy(),
"ADD THINGY"
)
self.assert_compile(DropThingy(),
"DROP THINGY"
)
from sqlalchemy.dialects.sqlite import base
self.assert_compile(AddThingy(),
"ADD SPECIAL SL THINGY",
dialect=base.dialect()
)
self.assert_compile(DropThingy(),
"DROP THINGY",
dialect=base.dialect()
)
@compiles(DropThingy, 'sqlite')
def visit_drop_thingy(thingy, compiler, **kw):
return "DROP SPECIAL SL THINGY"
self.assert_compile(DropThingy(),
"DROP SPECIAL SL THINGY",
dialect=base.dialect()
)
self.assert_compile(DropThingy(),
"DROP THINGY",
)
开发者ID:onetera,项目名称:scandatatransfer,代码行数:50,代码来源:test_compiler.py
示例2: test_types
def test_types(self):
class MyType(TypeEngine):
pass
@compiles(MyType, 'sqlite')
def visit_type(type, compiler, **kw):
return "SQLITE_FOO"
@compiles(MyType, 'postgresql')
def visit_type(type, compiler, **kw):
return "POSTGRES_FOO"
from sqlalchemy.dialects.sqlite import base as sqlite
from sqlalchemy.dialects.postgresql import base as postgresql
self.assert_compile(
MyType(),
"SQLITE_FOO",
dialect=sqlite.dialect()
)
self.assert_compile(
MyType(),
"POSTGRES_FOO",
dialect=postgresql.dialect()
)
开发者ID:onetera,项目名称:scandatatransfer,代码行数:26,代码来源:test_compiler.py
示例3: test_legacy_quoted_identifiers_unit
def test_legacy_quoted_identifiers_unit(self):
dialect = sqlite.dialect()
dialect._broken_fk_pragma_quotes = True
for row in [
(0, "target", "tid", "id"),
(0, '"target"', "tid", "id"),
(0, "[target]", "tid", "id"),
(0, "'target'", "tid", "id"),
(0, "`target`", "tid", "id"),
]:
fks = {}
fkeys = []
dialect._parse_fk(fks, fkeys, *row)
eq_(
fkeys,
[
{
"referred_table": "target",
"referred_columns": ["id"],
"referred_schema": None,
"name": None,
"constrained_columns": ["tid"],
}
],
)
开发者ID:niaolianyu,项目名称:sqlalchemy,代码行数:26,代码来源:test_sqlite.py
示例4: test_default_on_existing
def test_default_on_existing(self):
"""test that the existing compiler function remains
as 'default' when overriding the compilation of an
existing construct."""
t1 = table('t1', column('c1'), column('c2'))
dispatch = Select._compiler_dispatch
try:
@compiles(Select, 'sqlite')
def compile(element, compiler, **kw):
return "OVERRIDE"
s1 = select([t1])
self.assert_compile(
s1, "SELECT t1.c1, t1.c2 FROM t1",
)
from sqlalchemy.dialects.sqlite import base as sqlite
self.assert_compile(
s1, "OVERRIDE",
dialect=sqlite.dialect()
)
finally:
Select._compiler_dispatch = dispatch
if hasattr(Select, '_compiler_dispatcher'):
del Select._compiler_dispatcher
开发者ID:AndryulE,项目名称:kitsune,代码行数:29,代码来源:test_compiler.py
示例5: test_sqlite_autoincrement
def test_sqlite_autoincrement(self):
table = Table('autoinctable', MetaData(), Column('id', Integer,
primary_key=True), Column('x', Integer,
default=None), sqlite_autoincrement=True)
self.assert_compile(schema.CreateTable(table),
'CREATE TABLE autoinctable (id INTEGER NOT '
'NULL PRIMARY KEY AUTOINCREMENT, x INTEGER)'
, dialect=sqlite.dialect())
开发者ID:Callek,项目名称:sqlalchemy,代码行数:8,代码来源:test_sqlite.py
示例6: test_sqlite_no_autoincrement
def test_sqlite_no_autoincrement(self):
table = Table('noautoinctable', MetaData(), Column('id',
Integer, primary_key=True), Column('x', Integer,
default=None))
self.assert_compile(schema.CreateTable(table),
'CREATE TABLE noautoinctable (id INTEGER '
'NOT NULL, x INTEGER, PRIMARY KEY (id))',
dialect=sqlite.dialect())
开发者ID:Callek,项目名称:sqlalchemy,代码行数:8,代码来源:test_sqlite.py
示例7: test_sqlite_uses_juliandates
def test_sqlite_uses_juliandates(self):
import datetime
from sqlalchemy.dialects.sqlite.base import dialect
start = datetime.date(2011, 9, 1)
end = datetime.date(2011, 9, 6)
sqlite = dialect()
self.assertEqual(
str(self.day_difference(start, end).compile(dialect=sqlite)),
'CAST(julianday(?) - julianday(?) AS INT)')
开发者ID:curvetips,项目名称:s4u.sqlalchemy,代码行数:9,代码来源:test_func.py
示例8: test_sqlite_no_autoincrement
def test_sqlite_no_autoincrement(self):
table = Table(
"noautoinctable", MetaData(), Column("id", Integer, primary_key=True), Column("x", Integer, default=None)
)
self.assert_compile(
schema.CreateTable(table),
"CREATE TABLE noautoinctable (id INTEGER " "NOT NULL, x INTEGER, PRIMARY KEY (id))",
dialect=sqlite.dialect(),
)
开发者ID:niaolianyu,项目名称:sqlalchemy,代码行数:9,代码来源:test_sqlite.py
示例9: test_old_style_default
def test_old_style_default(self):
"""test non-quoted integer value on older sqlite pragma"""
dialect = sqlite.dialect()
eq_(
dialect._get_column_info("foo", "INTEGER", False, 3, False),
{'primary_key': False, 'nullable': False,
'default': '3', 'autoincrement': False,
'type': INTEGER, 'name': 'foo'}
)
开发者ID:MVReddy,项目名称:sqlalchemy,代码行数:10,代码来源:test_sqlite.py
示例10: test_sqlite_autoincrement_int_affinity
def test_sqlite_autoincrement_int_affinity(self):
class MyInteger(TypeDecorator):
impl = Integer
table = Table("autoinctable", MetaData(), Column("id", MyInteger, primary_key=True), sqlite_autoincrement=True)
self.assert_compile(
schema.CreateTable(table),
"CREATE TABLE autoinctable (id INTEGER NOT " "NULL PRIMARY KEY AUTOINCREMENT)",
dialect=sqlite.dialect(),
)
开发者ID:niaolianyu,项目名称:sqlalchemy,代码行数:10,代码来源:test_sqlite.py
示例11: _test_lookup_direct
def _test_lookup_direct(self, fixture, warnings=False):
dialect = sqlite.dialect()
for from_, to_ in self._fixture_as_string(fixture):
if warnings:
def go():
return dialect._resolve_type_affinity(from_)
final_type = testing.assert_warnings(go,
["Could not instantiate"], regex=True)
else:
final_type = dialect._resolve_type_affinity(from_)
expected_type = type(to_)
is_(type(final_type), expected_type)
开发者ID:Callek,项目名称:sqlalchemy,代码行数:12,代码来源:test_sqlite.py
示例12: test_sqlite_autoincrement
def test_sqlite_autoincrement(self):
table = Table(
"autoinctable",
MetaData(),
Column("id", Integer, primary_key=True),
Column("x", Integer, default=None),
sqlite_autoincrement=True,
)
self.assert_compile(
schema.CreateTable(table),
"CREATE TABLE autoinctable (id INTEGER NOT " "NULL PRIMARY KEY AUTOINCREMENT, x INTEGER)",
dialect=sqlite.dialect(),
)
开发者ID:niaolianyu,项目名称:sqlalchemy,代码行数:13,代码来源:test_sqlite.py
示例13: test_select
def test_select(self):
t1 = table("t1", column("c1"), column("c2"))
@compiles(Select, "sqlite")
def compile_(element, compiler, **kw):
return "OVERRIDE"
s1 = select([t1])
self.assert_compile(s1, "SELECT t1.c1, t1.c2 FROM t1")
from sqlalchemy.dialects.sqlite import base as sqlite
self.assert_compile(s1, "OVERRIDE", dialect=sqlite.dialect())
开发者ID:BY-jk,项目名称:sqlalchemy,代码行数:13,代码来源:test_compiler.py
示例14: test_sqlite_autoincrement_int_affinity
def test_sqlite_autoincrement_int_affinity(self):
class MyInteger(sqltypes.TypeDecorator):
impl = Integer
table = Table(
'autoinctable',
MetaData(),
Column('id', MyInteger, primary_key=True),
sqlite_autoincrement=True,
)
self.assert_compile(schema.CreateTable(table),
'CREATE TABLE autoinctable (id INTEGER NOT '
'NULL PRIMARY KEY AUTOINCREMENT)',
dialect=sqlite.dialect())
开发者ID:Callek,项目名称:sqlalchemy,代码行数:13,代码来源:test_sqlite.py
示例15: test_old_style_default
def test_old_style_default(self):
"""test non-quoted integer value on older sqlite pragma"""
dialect = sqlite.dialect()
eq_(
dialect._get_column_info("foo", "INTEGER", False, 3, False),
{
"primary_key": False,
"nullable": False,
"default": "3",
"autoincrement": False,
"type": INTEGER,
"name": "foo",
},
)
开发者ID:niaolianyu,项目名称:sqlalchemy,代码行数:15,代码来源:test_sqlite.py
示例16: test_no_convert_unicode
def test_no_convert_unicode(self):
"""test no utf-8 encoding occurs"""
dialect = sqlite.dialect()
for t in (
String(convert_unicode=True),
CHAR(convert_unicode=True),
Unicode(),
UnicodeText(),
String(convert_unicode=True),
CHAR(convert_unicode=True),
Unicode(),
UnicodeText(),
):
bindproc = t.dialect_impl(dialect).bind_processor(dialect)
assert not bindproc or isinstance(bindproc(util.u("some string")), util.text_type)
开发者ID:niaolianyu,项目名称:sqlalchemy,代码行数:16,代码来源:test_sqlite.py
示例17: test_select
def test_select(self):
t1 = table('t1', column('c1'), column('c2'))
@compiles(Select, 'sqlite')
def compile(element, compiler, **kw):
return "OVERRIDE"
s1 = select([t1])
self.assert_compile(
s1, "SELECT t1.c1, t1.c2 FROM t1",
)
from sqlalchemy.dialects.sqlite import base as sqlite
self.assert_compile(
s1, "OVERRIDE",
dialect=sqlite.dialect()
)
开发者ID:onetera,项目名称:scandatatransfer,代码行数:17,代码来源:test_compiler.py
示例18: test_legacy_quoted_identifiers_unit
def test_legacy_quoted_identifiers_unit(self):
dialect = sqlite.dialect()
dialect._broken_fk_pragma_quotes = True
for row in [
(0, 'target', 'tid', 'id'),
(0, '"target"', 'tid', 'id'),
(0, '[target]', 'tid', 'id'),
(0, "'target'", 'tid', 'id'),
(0, '`target`', 'tid', 'id'),
]:
fks = {}
fkeys = []
dialect._parse_fk(fks, fkeys, *row)
eq_(fkeys, [{
'referred_table': 'target',
'referred_columns': ['id'],
'referred_schema': None,
'name': None,
'constrained_columns': ['tid']
}])
开发者ID:Callek,项目名称:sqlalchemy,代码行数:22,代码来源:test_sqlite.py
示例19: test_sqlite_uses_max
def test_sqlite_uses_max(self):
from sqlalchemy.dialects.sqlite.base import dialect
sqlite = dialect()
self.assertEqual(
str(self.least(1, 2).compile(dialect=sqlite)),
'MIN(?, ?)')
开发者ID:curvetips,项目名称:s4u.sqlalchemy,代码行数:6,代码来源:test_func.py
示例20: test_sqlite_needs_two_arguments
def test_sqlite_needs_two_arguments(self):
from sqlalchemy.dialects.sqlite.base import dialect
sqlite = dialect()
self.assertRaises(ValueError,
self.day_difference(1, 2, 3).compile, dialect=sqlite)
开发者ID:curvetips,项目名称:s4u.sqlalchemy,代码行数:5,代码来源:test_func.py
注:本文中的sqlalchemy.dialects.sqlite.base.dialect函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论