本文整理汇总了Python中sqlite3.NotSupportedError方法的典型用法代码示例。如果您正苦于以下问题:Python sqlite3.NotSupportedError方法的具体用法?Python sqlite3.NotSupportedError怎么用?Python sqlite3.NotSupportedError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sqlite3
的用法示例。
在下文中一共展示了sqlite3.NotSupportedError方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CheckNotSupportedError
# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import NotSupportedError [as 别名]
def CheckNotSupportedError(self):
self.assertTrue(issubclass(sqlite.NotSupportedError,
sqlite.DatabaseError),
"NotSupportedError is not a subclass of DatabaseError")
示例2: CheckExceptions
# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import NotSupportedError [as 别名]
def CheckExceptions(self):
# Optional DB-API extension.
self.assertEqual(self.cx.Warning, sqlite.Warning)
self.assertEqual(self.cx.Error, sqlite.Error)
self.assertEqual(self.cx.InterfaceError, sqlite.InterfaceError)
self.assertEqual(self.cx.DatabaseError, sqlite.DatabaseError)
self.assertEqual(self.cx.DataError, sqlite.DataError)
self.assertEqual(self.cx.OperationalError, sqlite.OperationalError)
self.assertEqual(self.cx.IntegrityError, sqlite.IntegrityError)
self.assertEqual(self.cx.InternalError, sqlite.InternalError)
self.assertEqual(self.cx.ProgrammingError, sqlite.ProgrammingError)
self.assertEqual(self.cx.NotSupportedError, sqlite.NotSupportedError)
示例3: CheckOpenUri
# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import NotSupportedError [as 别名]
def CheckOpenUri(self):
if sqlite.sqlite_version_info < (3, 7, 7):
with self.assertRaises(sqlite.NotSupportedError):
sqlite.connect(':memory:', uri=True)
return
self.addCleanup(unlink, TESTFN)
with sqlite.connect(TESTFN) as cx:
cx.execute('create table test(id integer)')
with sqlite.connect('file:' + TESTFN, uri=True) as cx:
cx.execute('insert into test(id) values(0)')
with sqlite.connect('file:' + TESTFN + '?mode=ro', uri=True) as cx:
with self.assertRaises(sqlite.OperationalError):
cx.execute('insert into test(id) values(1)')
示例4: CheckSameThreadErrorOnOldVersion
# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import NotSupportedError [as 别名]
def CheckSameThreadErrorOnOldVersion(self):
with self.assertRaises(sqlite.NotSupportedError) as cm:
sqlite.connect(':memory:', check_same_thread=False)
self.assertEqual(str(cm.exception), 'shared connections not available')
示例5: try_executing_query
# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import NotSupportedError [as 别名]
def try_executing_query(prediction, cursor, case_sensitive=True, verbose=False):
"""Attempts to execute a SQL query against a database given a cursor."""
exception_str = None
prediction_str = prediction[:]
prediction_str = prediction_str.replace(';', '').strip()
print('Current prediction:' + prediction_str)
try:
if not case_sensitive:
new_prediction = ''
last_quote = ''
for char in prediction:
new_prediction += char
if char in {'"', '\''} and not last_quote:
last_quote = char
elif char == last_quote:
last_quote = ''
new_prediction += ' COLLATE NOCASE'
prediction = new_prediction
if verbose:
print('Executing case-insensitive query:')
print(new_prediction)
pred_results = timeout_execute(cursor, prediction)
except timeout_decorator.timeout_decorator.TimeoutError:
print('!time out!')
pred_results = []
exception_str = 'timeout'
except (sqlite3.Warning, sqlite3.Error, sqlite3.DatabaseError,
sqlite3.IntegrityError, sqlite3.ProgrammingError,
sqlite3.OperationalError, sqlite3.NotSupportedError) as e:
exception_str = str(e).lower()
pred_results = []
return pred_results, exception_str
示例6: CheckNotSupportedError
# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import NotSupportedError [as 别名]
def CheckNotSupportedError(self):
self.failUnless(issubclass(sqlite.NotSupportedError,
sqlite.DatabaseError),
'NotSupportedError is not a subclass of DatabaseError')