本文整理汇总了Python中executor.Executor.save方法的典型用法代码示例。如果您正苦于以下问题:Python Executor.save方法的具体用法?Python Executor.save怎么用?Python Executor.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类executor.Executor
的用法示例。
在下文中一共展示了Executor.save方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: delete
# 需要导入模块: from executor import Executor [as 别名]
# 或者: from executor.Executor import save [as 别名]
def delete(self):
kw = dict((self._basic_fields[i], self.values[i]) for i in self._pk)
kw['multi'] = None
kw['alias'] = self.__alias__
kw['uin'] = self._uin
w = ' AND '.join('%s = :%s' % (self._basic_fields[i], i) for i in self._pk)
if w:
w = 'WHERE ' + w
Executor.save('DELETE FROM %s %s' % (self.__table__, w), **kw)
示例2: save
# 需要导入模块: from executor import Executor [as 别名]
# 或者: from executor.Executor import save [as 别名]
def save(self, **kw):
isnew = kw.pop('isnew', any(self.values[i] is None for i in self._pk))
if self._dirty or isnew:
# set default volumes
for i in self._basic_fields.keys():
if self.values[i] is None:
x = self._fields[i]._default
if isinstance(x, (FunctionType, MethodType, BuiltinFunctionType, BuiltinMethodType,)):
x = x()
elif isinstance(x, Sequence):
# print 'W1', x
x = x()
# print 'W2', x
self.__setattr__(i, x)
kw = {'alias': self.__alias__}
if isnew:
fields = []
for i in self._dirty:
k = self._basic_fields[i]
kw[k] = self.values[i]
fields.append(k)
sql = 'INSERT INTO %s (%s) VALUES (%s)' % (self.__table__,
','.join(fields),
','.join(' :%s' % i for i in fields))
else:
sets = []
whr = []
for i in self._dirty:
k = self._basic_fields[i]
kw[k] = self.values[i]
sets.append('%s = :%s' % (k, k))
for pk in self._pk:
k = self._basic_fields[pk]
kw[k] = self.old_values[pk]
whr.append('%s = :%s' % (k, k))
sql = 'UPDATE %s SET %s WHERE %s' % (self.__table__,
', '.join(sets),
' AND '.join(whr))
self._dirty = []
kw['uin'] = self._uin
Executor.save(sql, **kw)