當前位置: 首頁>>代碼示例>>Python>>正文


Python DB.do_select方法代碼示例

本文整理匯總了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
開發者ID:jeremyfix,項目名稱:monepy,代碼行數:11,代碼來源:counter.py

示例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
開發者ID:jeremyfix,項目名稱:monepy,代碼行數:11,代碼來源:counter.py

示例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
開發者ID:jeremyfix,項目名稱:monepy,代碼行數:12,代碼來源:recording.py

示例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
開發者ID:jeremyfix,項目名稱:monepy,代碼行數:13,代碼來源:recording.py

示例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
開發者ID:jeremyfix,項目名稱:monepy,代碼行數:14,代碼來源:recording.py


注:本文中的db.DB.do_select方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。