本文整理匯總了Python中sqlite3.InternalError方法的典型用法代碼示例。如果您正苦於以下問題:Python sqlite3.InternalError方法的具體用法?Python sqlite3.InternalError怎麽用?Python sqlite3.InternalError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sqlite3
的用法示例。
在下文中一共展示了sqlite3.InternalError方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: CheckSingleProcessTimeoutsDeferred
# 需要導入模塊: import sqlite3 [as 別名]
# 或者: from sqlite3 import InternalError [as 別名]
def CheckSingleProcessTimeoutsDeferred(self):
fd, dbfile = tempfile.mkstemp()
os.close(fd)
# 2 second timeout
db1 = sqlite.connect(dbfile, timeout=2000)
db2 = sqlite.connect(dbfile)
cu2 = db2.cursor()
cu1 = db1.cursor()
cu1.execute('CREATE TABLE foo (bar)')
db1.commit()
cu2.execute('BEGIN DEFERRED')
cu2.execute('INSERT INTO foo VALUES(1)')
t1 = time.time()
try:
cu1.execute('BEGIN DEFERRED')
cu1.execute('INSERT INTO foo VALUES(2)')
except sqlite.InternalError, e:
assert(str(e) == "database is locked")
示例2: CheckSingleProcessTimeoutsOnBeginImmediate
# 需要導入模塊: import sqlite3 [as 別名]
# 或者: from sqlite3 import InternalError [as 別名]
def CheckSingleProcessTimeoutsOnBeginImmediate(self):
fd, dbfile = tempfile.mkstemp()
os.close(fd)
# 2 second timeout
db1 = sqlite.connect(dbfile, timeout=2000)
db2 = sqlite.connect(dbfile)
cu1 = db1.cursor()
cu2 = db2.cursor()
cu2.execute('BEGIN IMMEDIATE')
t1 = time.time()
try:
cu1.execute('BEGIN IMMEDIATE')
except sqlite.InternalError, e:
assert(str(e) == "database is locked")
示例3: CheckSingleProcessCallbacksDeferred
# 需要導入模塊: import sqlite3 [as 別名]
# 或者: from sqlite3 import InternalError [as 別名]
def CheckSingleProcessCallbacksDeferred(self):
fd, dbfile = tempfile.mkstemp()
os.close(fd)
db1 = sqlite.connect(dbfile)
waiter = Waiter()
db1.db.sqlite_busy_handler(waiter.wait)
db2 = sqlite.connect(dbfile)
cu2 = db2.cursor()
cu1 = db1.cursor()
cu1.execute('CREATE TABLE foo (bar)')
db1.commit()
cu2.execute('BEGIN DEFERRED')
cu2.execute('INSERT INTO foo VALUES(1)')
t1 = time.time()
try:
cu1.execute('BEGIN DEFERRED')
cu1.execute('INSERT INTO foo VALUES(2)')
except sqlite.InternalError, e:
assert(str(e) == "database is locked")
示例4: CheckInternalError
# 需要導入模塊: import sqlite3 [as 別名]
# 或者: from sqlite3 import InternalError [as 別名]
def CheckInternalError(self):
self.assertTrue(issubclass(sqlite.InternalError, sqlite.DatabaseError),
"InternalError is not a subclass of DatabaseError")
示例5: CheckExceptions
# 需要導入模塊: import sqlite3 [as 別名]
# 或者: from sqlite3 import InternalError [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)
示例6: CheckRollbackAfterError
# 需要導入模塊: import sqlite3 [as 別名]
# 或者: from sqlite3 import InternalError [as 別名]
def CheckRollbackAfterError(self):
import tempfile, os
fd, fn = tempfile.mkstemp()
os.close(fd)
db1 = sqlite.connect(fn)
db2 = sqlite.connect(fn)
cu1 = db1.cursor()
cu2 = db2.cursor()
cu1.execute('create table test(a)')
db1.commit()
cu1.execute('insert into test values(1)')
try:
cu2.execute('insert into test values(2)')
except sqlite.InternalError, e:
assert(str(e) == "database is locked")
示例7: CheckInternalError
# 需要導入模塊: import sqlite3 [as 別名]
# 或者: from sqlite3 import InternalError [as 別名]
def CheckInternalError(self):
self.failUnless(issubclass(sqlite.InternalError, sqlite.DatabaseError),
'InternalError is not a subclass of DatabaseError')