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


Python Query.format_type方法代码示例

本文整理汇总了Python中query.Query.format_type方法的典型用法代码示例。如果您正苦于以下问题:Python Query.format_type方法的具体用法?Python Query.format_type怎么用?Python Query.format_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在query.Query的用法示例。


在下文中一共展示了Query.format_type方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: save

# 需要导入模块: from query import Query [as 别名]
# 或者: from query.Query import format_type [as 别名]
 def save(self):
   # If it doesn't have an ID (Either nonexistant or not set), then call the
   # create() method to do an INSERT instead of an UPDATE.
   try:
     if not self.id: self.create()
   except AttributeError: self.create()
   base = 'UPDATE %s SET ' % self.Table
   diff = self.diff()
   fields = ''
   if not diff: return None
   # Build field and value list if there is a difference
   for key in diff:
     field = self._get_field_by_name(key)
     value = field.query(diff[key])
     fields += ', ' + field.name + ' = ' + Query.format_type(value)
   base += fields[2:] + ' WHERE id = ' + str(self.id)
   Query.query(base)
   # Right now, just spit back the instance of self
   return self
开发者ID:dirk,项目名称:constrictor,代码行数:21,代码来源:model.py

示例2: create

# 需要导入模块: from query import Query [as 别名]
# 或者: from query.Query import format_type [as 别名]
 def create(self):
   base = 'INSERT INTO %s ' % self.Table
   names = []
   values = []
   for f in self.Structure:
     try:
       # Try to get the attribute, else raise an exception if it can't be null.
       name = f.name
       value = Query.format_type(f.query(self.__getattribute__(name)))
       names.append(name);values.append(value)
     except AttributeError:
       primary = self.get_primary()
       if not f.null and f.name != primary.name:
         raise Exception, 'Field "%s" cannot be null' % f.name
   # Build the set of fields and VALUES.
   base += '(%s) ' % (', '.join(names))
   base += 'VALUES (%s)' % (', '.join(values))
   # Execute and dump the current instance's attribs into the _original.
   self.Query.query(base)
   self._original = self._build_original()
   # Spit yourself back!
   return self
开发者ID:dirk,项目名称:constrictor,代码行数:24,代码来源:model.py


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