本文整理汇总了Python中domogik.common.database.DbHelper.get_db_type方法的典型用法代码示例。如果您正苦于以下问题:Python DbHelper.get_db_type方法的具体用法?Python DbHelper.get_db_type怎么用?Python DbHelper.get_db_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类domogik.common.database.DbHelper
的用法示例。
在下文中一共展示了DbHelper.get_db_type方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: check_args
# 需要导入模块: from domogik.common.database import DbHelper [as 别名]
# 或者: from domogik.common.database.DbHelper import get_db_type [as 别名]
def check_args(argv):
"""Check arguments passed to the program"""
def usage(prog_name):
"""Print program usage"""
print("Usage : %s [-s [all|minute[,hour][,day][,week][,month[,year]]] [-I]" % prog_name)
print("-s, --statistics=STATS_LIST\tSTATS_LIST can be : all or minute,hours,day,week,month,year")
print("-I, --noinsert\t\t\tUse existing data in the database")
if __name__ == "__main__":
stats_filter = False
try:
opts, args = getopt.getopt(sys.argv[1:], "hs:I", ["help", "stats=", "noinsert"])
_db = DbHelper(use_test_db=True)
print("Using %s database" % _db.get_db_type())
for opt, arg_list in opts:
if opt in ("-s", "--stats"):
possible_args = ['all', 'minute', 'hour', 'day', 'week', 'month', 'year']
if arg_list is not None:
filter_list = arg_list.split(",")
# Check args are ok for -s option
for p_filter in filter_list:
if p_filter not in filter_list:
print("Wrong argument for statistics, must be one of : %s" % (",".join(possible_args)))
usage(sys.argv[0])
if 'all' in filter_list:
filter_list = possible_args[1:]
stats_filter = True
elif opt in ("-h", "--help"):
示例2: len
# 需要导入模块: from domogik.common.database import DbHelper [as 别名]
# 或者: from domogik.common.database.DbHelper import get_db_type [as 别名]
for user in l_user:
assert user.login != 'domo'
person1_id = person1.id
person_del = db.del_person(person1.id)
assert person_del.id == person1_id
assert len(db.list_persons()) == 2
assert len(db.list_user_accounts()) == 1
try:
db.del_person(12345678910)
TestCase.fail(self, "Person does not exist, an exception should have been raised")
except DbHelperException:
pass
try:
db.del_user_account(12345678910)
TestCase.fail(self, "User account does not exist, an exception should have been raised")
except DbHelperException:
pass
if __name__ == "__main__":
print("Creating test database...")
db = DbHelper(use_test_db=True)
url = db.get_url_connection_string()
test_url = '%s_test' % url
engine_test = create_engine(test_url)
sql_schema.metadata.reflect(engine_test)
sql_schema.metadata.drop_all(engine_test)
sql_schema.metadata.create_all(engine_test)
print("*** Using database %s ***\n" % db.get_db_type())
unittest.main()