本文整理汇总了Python中executor.Executor.exec_sql方法的典型用法代码示例。如果您正苦于以下问题:Python Executor.exec_sql方法的具体用法?Python Executor.exec_sql怎么用?Python Executor.exec_sql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类executor.Executor
的用法示例。
在下文中一共展示了Executor.exec_sql方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __call__
# 需要导入模块: from executor import Executor [as 别名]
# 或者: from executor.Executor import exec_sql [as 别名]
def __call__(self, parent):
if isinstance(self._cls, basestring):
self._cls = Executor.classes[self._cls]
# codtition
if self._condition:
c1, c2 = [i.strip() for i in self._condition.split('=')]
if c2.startswith(parent.__class__.__name__ + '.'):
c1, c2 = c2, c1
c1a, c1b = c1.split('.')
c2a, c2b = c2.split('.')
if parent.__class__.__name__ <> c1a or self._cls.__name__ <> c2a:
raise ReferenceException('Invalid condition "%s" by classes "%s" and "%s"' % (self._condition, c1, c2))
return self._cls._read(self._multi, **{c2b:parent.values[c1b]})
# if function of SQL generating
elif self._generator:
if isinstance(self._generator, basestring):
self._generator = parent.__class__.__dict__[self._generator]
sql, kw = self._generator(parent)
# None-классы т.е. SQL-функции
if self._cls is None:
return Executor.exec_sql(sql, multi=False, **kw).data[0]
# Внешние классы
else:
return self._cls._read(self._multi, sql=sql, **kw)
示例2: __call__
# 需要导入模块: from executor import Executor [as 别名]
# 或者: from executor.Executor import exec_sql [as 别名]
def __call__(self):
sql = "SELECT %s.nextval FROM dual" % self.sec
return Executor.exec_sql(sql, multi=False, alias=self.alias)['data'][0]