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


Python DbHelper.upgrade_do方法代碼示例

本文整理匯總了Python中domogik.common.database.DbHelper.upgrade_do方法的典型用法代碼示例。如果您正苦於以下問題:Python DbHelper.upgrade_do方法的具體用法?Python DbHelper.upgrade_do怎麽用?Python DbHelper.upgrade_do使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在domogik.common.database.DbHelper的用法示例。


在下文中一共展示了DbHelper.upgrade_do方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: print

# 需要導入模塊: from domogik.common.database import DbHelper [as 別名]
# 或者: from domogik.common.database.DbHelper import upgrade_do [as 別名]
                        print("New device:      {0}({1})".format(newDev[(seln - 1)]["name"], newDev[(seln - 1)]['id']))
                        print("New sensor:      {0}({1})".format(newDev[(seln - 1)]["sensors"][selS]["name"], newDev[(seln - 1)]["sensors"][selS]["id"]))
                        print("")
                        print("WARNING:")
                        print("By typing YES below this will start the upgrade process, after the process")
                        print("the upgraded stats keys will be DELETED from the core_device_stats sql tabel.")
                        print("This process can not be reversed, it is advised to make a backup of your")
                        print("datatabse before starting this process")
                        print("")
                        conf = ""
                        while conf not in ["YES I AM SURE", "no"]:
                            conf = raw_input("Type 'YES I AM SURE' to confirm, 'no' to cancel: ")
                        if conf == "YES I AM SURE":
                            print("Copying the stats")
                            print("This can take some time be patient")
                            db.upgrade_do(selDev['id'], selKey, newDev[(seln - 1)]['id'], newDev[(seln - 1)]["sensors"][selS]["id"])
                            # check if this is the last key
                            if len(old_devs[selDev['id']]['keys']) == 1:
                                print("This was the last key of the device, so deleting the device")
                                db.del_device(selDev['id'])
                            print("Upgrade DONE")
                            print ""
                        else:
                            print("Upgrade CANCELED")

        else:
            do = False
        # close all
        db.close_session()
        if do:
            db.open_session()
開發者ID:Nico0084,項目名稱:domogik,代碼行數:33,代碼來源:statsUpgrade.py


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