当前位置: 首页>>代码示例>>Python>>正文


Python Executor.save方法代码示例

本文整理汇总了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)
开发者ID:uve,项目名称:shiva,代码行数:13,代码来源:engine.py

示例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)
开发者ID:uve,项目名称:shiva,代码行数:51,代码来源:engine.py


注:本文中的executor.Executor.save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。