本文整理汇总了Python中DBManager.DBManager.getSession方法的典型用法代码示例。如果您正苦于以下问题:Python DBManager.getSession方法的具体用法?Python DBManager.getSession怎么用?Python DBManager.getSession使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBManager.DBManager
的用法示例。
在下文中一共展示了DBManager.getSession方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update
# 需要导入模块: from DBManager import DBManager [as 别名]
# 或者: from DBManager.DBManager import getSession [as 别名]
def update(self):
db = DBManager()
sessionData = db.getSession(self.phrase)
db.close()
self.setLocals(sessionData)
示例2:
# 需要导入模块: from DBManager import DBManager [as 别名]
# 或者: from DBManager.DBManager import getSession [as 别名]
try:
db.createSession(ses)
except SessionError as se:
print "\t(-) Failed to create session! Already Exists"
print "\t(+) Session created!"
#---------------------------------------------------------------------------------------------------------#
print "(=) Testing Failure of createSession function"
try:
db.createSession(ses)
print "\t(-) Failure of createSession Test Failed"
except SessionError as se:
print "\t(+) Failure of createSession Test Passed. Error Caught:", se.msg
#---------------------------------------------------------------------------------------------------------#
print "(=) Testing Failure of getSession function"
try:
db.getSession('invalidphrase')
print "\t(-) Failure of getSession Test Failed"
except SessionError as se:
print "\t(+) Failure of getSession Test Passed. Error Caught:", se.msg
#---------------------------------------------------------------------------------------------------------#
print "(=) Setting period of %s to 1 day." % ses
db.setSessionPeriod(ses, 1)
#---------------------------------------------------------------------------------------------------------#
print "(=) Testing Failure of setSessionPeriod function"
try:
db.setSessionPeriod(ses, 'invalid duration')
print "\t(-) Failure of setSessionPeriod Test Failed"
except ValueError as ve:
print "\t(+) Failure of setSessionPeriod Test Passed. Error Caught:", ve
#---------------------------------------------------------------------------------------------------------#
print "(=) Testing getSessions function"