当前位置: 首页>>代码示例>>Python>>正文


Python sqlite3.InterfaceError方法代码示例

本文整理汇总了Python中sqlite3.InterfaceError方法的典型用法代码示例。如果您正苦于以下问题:Python sqlite3.InterfaceError方法的具体用法?Python sqlite3.InterfaceError怎么用?Python sqlite3.InterfaceError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sqlite3的用法示例。


在下文中一共展示了sqlite3.InterfaceError方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: CheckRollbackCursorConsistency

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import InterfaceError [as 别名]
def CheckRollbackCursorConsistency(self):
        """
        Checks if cursors on the connection are set into a "reset" state
        when a rollback is done on the connection.
        """
        con = sqlite.connect(":memory:")
        cur = con.cursor()
        cur.execute("create table test(x)")
        cur.execute("insert into test(x) values (5)")
        cur.execute("select 1 union select 2 union select 3")

        con.rollback()
        try:
            cur.fetchall()
            self.fail("InterfaceError should have been raised")
        except sqlite.InterfaceError, e:
            pass 
开发者ID:vmware-archive,项目名称:vsphere-storage-for-docker,代码行数:19,代码来源:transactions.py

示例2: CheckRollbackCursorConsistency

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import InterfaceError [as 别名]
def CheckRollbackCursorConsistency(self):
        """
        Checks if cursors on the connection are set into a "reset" state
        when a rollback is done on the connection.
        """
        con = sqlite.connect(":memory:")
        cur = con.cursor()
        cur.execute("create table test(x)")
        cur.execute("insert into test(x) values (5)")
        cur.execute("select 1 union select 2 union select 3")

        con.rollback()
        try:
            cur.fetchall()
            self.fail("InterfaceError should have been raised")
        except sqlite.InterfaceError as e:
            pass
        except:
            self.fail("InterfaceError should have been raised") 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:21,代码来源:transactions.py

示例3: CheckCursorRegistration

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import InterfaceError [as 别名]
def CheckCursorRegistration(self):
        """
        Verifies that subclassed cursor classes are correctly registered with
        the connection object, too.  (fetch-across-rollback problem)
        """
        class Connection(sqlite.Connection):
            def cursor(self):
                return Cursor(self)

        class Cursor(sqlite.Cursor):
            def __init__(self, con):
                sqlite.Cursor.__init__(self, con)

        con = Connection(":memory:")
        cur = con.cursor()
        cur.execute("create table foo(x)")
        cur.executemany("insert into foo(x) values (?)", [(3,), (4,), (5,)])
        cur.execute("select x from foo")
        con.rollback()
        with self.assertRaises(sqlite.InterfaceError):
            cur.fetchall() 
开发者ID:CedricGuillemet,项目名称:Imogen,代码行数:23,代码来源:regression.py

示例4: test_binding_param_0_error

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import InterfaceError [as 别名]
def test_binding_param_0_error(self):
        # test real param 0 binding errors

        for supported_type in [str, int, bytes]:
            await self.loop.run_in_executor(
                self.executor, self.db.executemany, "insert into test2 values (?, NULL)",
                [(supported_type(1), ), (supported_type(2), )]
            )
            await self.loop.run_in_executor(
                self.executor, self.db.execute, "delete from test2 where id in (1, 2)"
            )
        for unsupported_type in [lambda x: (x, ), lambda x: [x], lambda x: {x}]:
            try:
                await self.loop.run_in_executor(
                    self.executor, self.db.executemany, "insert into test2 (id, val) values (?, NULL)",
                    [(unsupported_type(1), ), (unsupported_type(2), )]
                )
                self.assertTrue(False)
            except sqlite3.InterfaceError as err:
                self.assertEqual(str(err), "Error binding parameter 0 - probably unsupported type.") 
开发者ID:lbryio,项目名称:lbry-sdk,代码行数:22,代码来源:test_database.py

示例5: do_full_login

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import InterfaceError [as 别名]
def do_full_login(account):
    lock_network.acquire()
    time.sleep(locktime)
    lock_network.release()
    if account['type'] == 'ptc':
        login_ptc(account)
    elif account['type'] == 'google':
        login_google(account)
        new_session(account)
    else:
        lprint('[{}] Error: Login type should be either ptc or google.'.format(account['num']))
        sys.exit()

    cursor_accs = db_accs.cursor()
    while True:
        try:
            cursor_accs.execute("INSERT OR REPLACE INTO accounts VALUES(?,?,?,?,?,?,?)", [account['user'], account['access_token'], account['access_expire_timestamp'], account['api_url'], 0, '0', '0'])
            db_accs.commit()
            return
        except sqlite3.OperationalError as e:
            lprint('[-] Sqlite operational error: {}, account: {} Retrying...'.format(e, account['user']))
        except sqlite3.InterfaceError as e:
            lprint('[-] Sqlite interface error: {}, account: {} Retrying...'.format(e, account['user'])) 
开发者ID:seikur0,项目名称:PGO-mapscan-opt,代码行数:25,代码来源:main0.py

示例6: CheckInterfaceError

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import InterfaceError [as 别名]
def CheckInterfaceError(self):
        self.assertTrue(issubclass(sqlite.InterfaceError, sqlite.Error),
                        "InterfaceError is not a subclass of Error") 
开发者ID:vmware-archive,项目名称:vsphere-storage-for-docker,代码行数:5,代码来源:dbapi.py

示例7: CheckExceptions

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import InterfaceError [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) 
开发者ID:vmware-archive,项目名称:vsphere-storage-for-docker,代码行数:14,代码来源:dbapi.py

示例8: CheckCursorRegistration

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import InterfaceError [as 别名]
def CheckCursorRegistration(self):
        """
        Verifies that subclassed cursor classes are correctly registered with
        the connection object, too.  (fetch-across-rollback problem)
        """
        class Connection(sqlite.Connection):
            def cursor(self):
                return Cursor(self)

        class Cursor(sqlite.Cursor):
            def __init__(self, con):
                sqlite.Cursor.__init__(self, con)

        con = Connection(":memory:")
        cur = con.cursor()
        cur.execute("create table foo(x)")
        cur.executemany("insert into foo(x) values (?)", [(3,), (4,), (5,)])
        cur.execute("select x from foo")
        con.rollback()
        try:
            cur.fetchall()
            self.fail("should have raised InterfaceError")
        except sqlite.InterfaceError:
            pass
        except:
            self.fail("should have raised InterfaceError") 
开发者ID:vmware-archive,项目名称:vsphere-storage-for-docker,代码行数:28,代码来源:regression.py

示例9: CheckUnsupportedSeq

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import InterfaceError [as 别名]
def CheckUnsupportedSeq(self):
        class Bar: pass
        val = Bar()
        try:
            self.cur.execute("insert into test(f) values (?)", (val,))
            self.fail("should have raised an InterfaceError")
        except sqlite.InterfaceError:
            pass
        except:
            self.fail("should have raised an InterfaceError") 
开发者ID:vmware-archive,项目名称:vsphere-storage-for-docker,代码行数:12,代码来源:types.py


注:本文中的sqlite3.InterfaceError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。