本文整理匯總了Python中db.DB.do_select方法的典型用法代碼示例。如果您正苦於以下問題:Python DB.do_select方法的具體用法?Python DB.do_select怎麽用?Python DB.do_select使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類db.DB
的用法示例。
在下文中一共展示了DB.do_select方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: findById
# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import do_select [as 別名]
def findById(id):
query = "select * from counters where id=%i" % id
res = DB.do_select(query)
if len(res) != 1:
raise Exception("Issue while requesting counter id=%i ; got %i results" % (id, len(res)))
c = Counter(res[0][1])
c.id = res[0][0]
return c
示例2: findAll
# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import do_select [as 別名]
def findAll():
query = "select * from counters"
res = DB.do_select(query)
allc = []
for (id, name) in res:
c = Counter(name)
c.id = id
allc.append(c)
return allc
示例3: findByIdCounter
# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import do_select [as 別名]
def findByIdCounter(idcounter):
query = "select * from recordings where idcounter=%i" % idcounter
res = DB.do_select(query)
allr = []
for (id, idcounter, date, value) in res:
d = datetime.datetime.strptime(date[:-4], "%Y-%m-%d %H:%M:%S")
r = Recording(idcounter, d, value)
r.id = id
allr.append(r)
return allr
示例4: findAll
# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import do_select [as 別名]
def findAll():
query = "select * from recordings"
res = DB.do_select(query)
allr = []
for (id, idcounter, date, value) in res:
# the date is recorded as a string with trailing millisecondes; see insert()
d = datetime.datetime.strptime(date[:-4], "%Y-%m-%d %H:%M:%S")
r = Recording(idcounter, d, value)
r.id = id
allr.append(r)
return allr
示例5: findById
# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import do_select [as 別名]
def findById(id):
query = "select * from recordings where id=%i" % id
res = DB.do_select(query)
allr = []
if len(res) != 1:
raise Exception("Not enough or too many results !!")
(id, idcounter, date, value) = res[0]
d = datetime.datetime.strptime(date[:-4], "%Y-%m-%d %H:%M:%S")
r = Recording(idcounter, d, value)
r.id = id
return r