本文整理汇总了Python中sql.Flavor.get方法的典型用法代码示例。如果您正苦于以下问题:Python Flavor.get方法的具体用法?Python Flavor.get怎么用?Python Flavor.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sql.Flavor
的用法示例。
在下文中一共展示了Flavor.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __str__
# 需要导入模块: from sql import Flavor [as 别名]
# 或者: from sql.Flavor import get [as 别名]
def __str__(self):
Mapping = Flavor.get().function_mapping.get(self.__class__)
if Mapping:
return str(Mapping(*self.args))
param = Flavor.get().param
def format(arg):
if isinstance(arg, basestring):
return param
else:
return str(arg)
return self._function + '(' + ', '.join(map(format, self.args)) + ')'
示例2: __str__
# 需要导入模块: from sql import Flavor [as 别名]
# 或者: from sql.Flavor import get [as 别名]
def __str__(self):
Mapping = Flavor.get().function_mapping.get(self.__class__)
if Mapping:
return str(Mapping(self.string, self.position, self.characters))
param = Flavor.get().param
def format(arg):
if isinstance(arg, basestring):
return param
else:
return str(arg)
return self._function + "(%s %s FROM %s)" % (self.position, format(self.characters), format(self.string))
示例3: __str__
# 需要导入模块: from sql import Flavor [as 别名]
# 或者: from sql.Flavor import get [as 别名]
def __str__(self):
flavor = Flavor.get()
Mapping = flavor.function_mapping.get(self.__class__)
if Mapping:
return str(Mapping(self.field, self.zone))
param = flavor.param
return str(self.field) + " AT TIME ZONE " + param
示例4: test_select_union_flavor
# 需要导入模块: from sql import Flavor [as 别名]
# 或者: from sql.Flavor import get [as 别名]
def test_select_union_flavor(self):
flavor = Flavor.get()
prev = flavor.quote_character
flavor.quote_character = '`'
self._test_select_union_quote('`')
flavor.quote_character = prev
Flavor.set(flavor)
示例5: _format
# 需要导入模块: from sql import Flavor [as 别名]
# 或者: from sql.Flavor import get [as 别名]
def _format(self, operand, param=None):
if param is None:
param = Flavor.get().param
if isinstance(operand, Expression):
return str(operand)
elif isinstance(operand, (Select, CombiningQuery)):
return '(' + operand + ')'
# return '(%s)' % operand
elif isinstance(operand, (list, tuple)):
subStrings = []
for o in operand:
subStrings.append(self._format(o, param))
joinedString = ""
for joiningIndex in range(len(subStrings)):
joinedString = joinedString + subStrings[joiningIndex]
if joiningIndex != len(subStrings) - 1:
joinedString = joinedString + ", "
return '(' + joinedString + ')'
elif isinstance(operand, array):
subStrings = (param,) * len(operand)
joinedString = ""
for joiningIndex in range(len(subStrings)):
joinedString = joinedString + subStrings[joiningIndex]
if joiningIndex != len(subStrings) - 1:
joinedString = joinedString + ", "
return '(' + joinedString + ')'
else:
return param
示例6: __str__
# 需要导入模块: from sql import Flavor [as 别名]
# 或者: from sql.Flavor import get [as 别名]
def __str__(self):
Mapping = Flavor.get().function_mapping.get(self.__class__)
if Mapping:
return str(Mapping(*self.args))
return (self._function + '('
+ ' '.join(chain(*zip(
self._keywords,
map(self._format, self.args))))[1:]
+ ')')
示例7: __str__
# 需要导入模块: from sql import Flavor [as 别名]
# 或者: from sql.Flavor import get [as 别名]
def __str__(self):
param = Flavor.get().param
def format(value):
if isinstance(value, basestring):
return param
else:
return str(value)
return (self._conditional
+ '(' + ', '.join(map(format, self.values)) + ')')
示例8: _format
# 需要导入模块: from sql import Flavor [as 别名]
# 或者: from sql.Flavor import get [as 别名]
def _format(self, operand):
param = Flavor.get().param
if isinstance(operand, Expression):
return str(operand)
elif isinstance(operand, (Select, CombiningQuery)):
return '(%s)' % operand
elif isinstance(operand, (list, tuple)):
return '(' + ', '.join(self._format(o) for o in operand) + ')'
else:
return param
示例9: params
# 需要导入模块: from sql import Flavor [as 别名]
# 或者: from sql.Flavor import get [as 别名]
def params(self):
Mapping = Flavor.get().function_mapping.get(self.__class__)
if Mapping:
return Mapping(self.string, self.position, self.characters).params
p = []
for arg in (self.characters, self.string):
if isinstance(arg, basestring):
p.append(arg)
elif hasattr(arg, 'params'):
p.extend(arg.params)
return tuple(p)
示例10: create_sql_sequence
# 需要导入模块: from sql import Flavor [as 别名]
# 或者: from sql.Flavor import get [as 别名]
def create_sql_sequence(self, number_next=None):
'Create the SQL sequence'
cursor = Transaction().connection.cursor()
param = Flavor.get().param
if self.type != 'incremental':
return
if number_next is None:
number_next = self.number_next
cursor.execute('CREATE SEQUENCE "' + self._sql_sequence_name
+ '" INCREMENT BY ' + param + ' START WITH ' + param,
(self.number_increment, number_next))
示例11: params
# 需要导入模块: from sql import Flavor [as 别名]
# 或者: from sql.Flavor import get [as 别名]
def params(self):
Mapping = Flavor.get().function_mapping.get(self.__class__)
if Mapping:
return Mapping(*self.args).params
p = ()
for arg in (self.characters, self.string):
if isinstance(arg, basestring):
p += (arg,)
elif hasattr(arg, "params"):
p += arg.params
return p
示例12: _format
# 需要导入模块: from sql import Flavor [as 别名]
# 或者: from sql.Flavor import get [as 别名]
def _format(operand):
param = Flavor.get().param
if isinstance(operand, Column):
return str(operand)
elif isinstance(operand, Select):
return '(%s)' % operand
elif isinstance(operand, (list, tuple)):
return '(' + ', '.join((param,) * len(operand)) + ')'
elif operand is None:
return ''
else:
return param
示例13: _format
# 需要导入模块: from sql import Flavor [as 别名]
# 或者: from sql.Flavor import get [as 别名]
def _format(self, operand, param=None):
if param is None:
param = Flavor.get().param
if isinstance(operand, Expression):
return str(operand)
elif isinstance(operand, (Select, CombiningQuery)):
return "(%s)" % operand
elif isinstance(operand, (list, tuple)):
return "(" + ", ".join(self._format(o, param) for o in operand) + ")"
elif isinstance(operand, array):
return "(" + ", ".join((param,) * len(operand)) + ")"
else:
return param
示例14: update_sql_sequence
# 需要导入模块: from sql import Flavor [as 别名]
# 或者: from sql.Flavor import get [as 别名]
def update_sql_sequence(self, number_next=None):
'Update the SQL sequence'
TableHandler = backend.get('TableHandler')
cursor = Transaction().connection.cursor()
param = Flavor.get().param
exist = TableHandler.sequence_exist(self._sql_sequence_name)
if self.type != 'incremental':
if exist:
self.delete_sql_sequence()
return
if not exist:
self.create_sql_sequence(number_next)
return
if number_next is None:
number_next = self.number_next
cursor.execute('ALTER SEQUENCE "' + self._sql_sequence_name
+ '" INCREMENT BY ' + param + ' RESTART WITH ' + param,
(self.number_increment, number_next))
示例15: _operands
# 需要导入模块: from sql import Flavor [as 别名]
# 或者: from sql.Flavor import get [as 别名]
def _operands(self):
operands = super(ILike, self)._operands
if not Flavor.get().ilike:
from .functions import Upper
operands = tuple(Upper(o) for o in operands)
return operands