本文整理汇总了Python中query.Query.query方法的典型用法代码示例。如果您正苦于以下问题:Python Query.query方法的具体用法?Python Query.query怎么用?Python Query.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类query.Query
的用法示例。
在下文中一共展示了Query.query方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: exist
# 需要导入模块: from query import Query [as 别名]
# 或者: from query.Query import query [as 别名]
def exist(cls, where=None, uuid=None):
where = where or {}
if uuid:
where['uuid'] = uuid
q = Query(cls).select(["count(*)"]).where(where).limit(1)
sql, where = q.query()
connection.my_connection().execute(sql, where)
results = connection.my_connection().fetchall()
return results[0][0] > 0
示例2: save
# 需要导入模块: from query import Query [as 别名]
# 或者: from query.Query import query [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