本文整理匯總了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()