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


Python DBUtil.int_to_ctime方法代码示例

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


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

示例1: _insert_row

# 需要导入模块: import DBUtil [as 别名]
# 或者: from DBUtil import int_to_ctime [as 别名]
 def _insert_row(self, cur, forcedTime=None):
   sql = "INSERT INTO %s" % (self._get_table_name())
   keys = []
   values = []
   for key, value in self.__dict__.iteritems():
     if _isCallable(value): 
       continue
     if key == "eventName":
       continue
     if key == "eventTime":
       if forcedTime:
         value = forcedTime
       else:
         value = DBUtil.int_to_ctime(value)
     keys.append(key)
     values.append(value)
   sql = sql + " (%s) VALUES (%s)" % (", ".join(keys), ", ".join(["%s"]*len(keys)))
   return cur.execute(sql, values)
开发者ID:clawplach,项目名称:BitBlinder,代码行数:20,代码来源:Events.py

示例2: insert

# 需要导入模块: import DBUtil [as 别名]
# 或者: from DBUtil import int_to_ctime [as 别名]
 def insert(self, cur):
   #figure out what hour this event supposedly happened in:
   assert type(self.eventTime) == types.IntType, "eventTime must be an integer number of seconds!"
   exactTime = self.eventTime - (self.eventTime % _AGGREGATE_INTERVAL)
   exactTime = DBUtil.int_to_ctime(exactTime)
   #check if there is an existing row for this time and source:
   sql = "SELECT COUNT(*) FROM %s" % (self._get_table_name())
   sql += " WHERE eventTime = %s and source = %s;"
   cur.execute(sql, (exactTime, self.source))
   numRows = cur.fetchone()[0]
   if numRows > 0:
     assert numRows == 1, "Should never be multiple rows for the same time and source!"
     #update that row with the new count:
     sql = "UPDATE %s" % (self._get_table_name())
     sql += " SET amount = amount + %s WHERE eventTime = %s and source = %s;"
     return cur.execute(sql, (self.amount, exactTime, self.source))
   else:
     #insert a new row:
     return self._insert_row(cur, exactTime)
开发者ID:clawplach,项目名称:BitBlinder,代码行数:21,代码来源:Events.py


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