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


Python sqlite3.ProgrammingError方法代码示例

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


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

示例1: CheckConCursor

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import ProgrammingError [as 别名]
def CheckConCursor(self):
        def run(con, errors):
            try:
                cur = con.cursor()
                errors.append("did not raise ProgrammingError")
                return
            except sqlite.ProgrammingError:
                return
            except:
                errors.append("raised wrong exception")

        errors = []
        t = threading.Thread(target=run, kwargs={"con": self.con, "errors": errors})
        t.start()
        t.join()
        if len(errors) > 0:
            self.fail("\n".join(errors)) 
开发者ID:vmware-archive,项目名称:vsphere-storage-for-docker,代码行数:19,代码来源:dbapi.py

示例2: CheckConCommit

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import ProgrammingError [as 别名]
def CheckConCommit(self):
        def run(con, errors):
            try:
                con.commit()
                errors.append("did not raise ProgrammingError")
                return
            except sqlite.ProgrammingError:
                return
            except:
                errors.append("raised wrong exception")

        errors = []
        t = threading.Thread(target=run, kwargs={"con": self.con, "errors": errors})
        t.start()
        t.join()
        if len(errors) > 0:
            self.fail("\n".join(errors)) 
开发者ID:vmware-archive,项目名称:vsphere-storage-for-docker,代码行数:19,代码来源:dbapi.py

示例3: CheckConClose

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import ProgrammingError [as 别名]
def CheckConClose(self):
        def run(con, errors):
            try:
                con.close()
                errors.append("did not raise ProgrammingError")
                return
            except sqlite.ProgrammingError:
                return
            except:
                errors.append("raised wrong exception")

        errors = []
        t = threading.Thread(target=run, kwargs={"con": self.con, "errors": errors})
        t.start()
        t.join()
        if len(errors) > 0:
            self.fail("\n".join(errors)) 
开发者ID:vmware-archive,项目名称:vsphere-storage-for-docker,代码行数:19,代码来源:dbapi.py

示例4: CheckCurImplicitBegin

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import ProgrammingError [as 别名]
def CheckCurImplicitBegin(self):
        def run(cur, errors):
            try:
                cur.execute("insert into test(name) values ('a')")
                errors.append("did not raise ProgrammingError")
                return
            except sqlite.ProgrammingError:
                return
            except:
                errors.append("raised wrong exception")

        errors = []
        t = threading.Thread(target=run, kwargs={"cur": self.cur, "errors": errors})
        t.start()
        t.join()
        if len(errors) > 0:
            self.fail("\n".join(errors)) 
开发者ID:vmware-archive,项目名称:vsphere-storage-for-docker,代码行数:19,代码来源:dbapi.py

示例5: CheckCurClose

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import ProgrammingError [as 别名]
def CheckCurClose(self):
        def run(cur, errors):
            try:
                cur.close()
                errors.append("did not raise ProgrammingError")
                return
            except sqlite.ProgrammingError:
                return
            except:
                errors.append("raised wrong exception")

        errors = []
        t = threading.Thread(target=run, kwargs={"cur": self.cur, "errors": errors})
        t.start()
        t.join()
        if len(errors) > 0:
            self.fail("\n".join(errors)) 
开发者ID:vmware-archive,项目名称:vsphere-storage-for-docker,代码行数:19,代码来源:dbapi.py

示例6: CheckCurExecute

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import ProgrammingError [as 别名]
def CheckCurExecute(self):
        def run(cur, errors):
            try:
                cur.execute("select name from test")
                errors.append("did not raise ProgrammingError")
                return
            except sqlite.ProgrammingError:
                return
            except:
                errors.append("raised wrong exception")

        errors = []
        self.cur.execute("insert into test(name) values ('a')")
        t = threading.Thread(target=run, kwargs={"cur": self.cur, "errors": errors})
        t.start()
        t.join()
        if len(errors) > 0:
            self.fail("\n".join(errors)) 
开发者ID:vmware-archive,项目名称:vsphere-storage-for-docker,代码行数:20,代码来源:dbapi.py

示例7: CheckCurIterNext

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import ProgrammingError [as 别名]
def CheckCurIterNext(self):
        def run(cur, errors):
            try:
                row = cur.fetchone()
                errors.append("did not raise ProgrammingError")
                return
            except sqlite.ProgrammingError:
                return
            except:
                errors.append("raised wrong exception")

        errors = []
        self.cur.execute("insert into test(name) values ('a')")
        self.cur.execute("select name from test")
        t = threading.Thread(target=run, kwargs={"cur": self.cur, "errors": errors})
        t.start()
        t.join()
        if len(errors) > 0:
            self.fail("\n".join(errors)) 
开发者ID:vmware-archive,项目名称:vsphere-storage-for-docker,代码行数:21,代码来源:dbapi.py

示例8: CheckClosedCreateAggregate

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import ProgrammingError [as 别名]
def CheckClosedCreateAggregate(self):
        con = sqlite.connect(":memory:")
        con.close()
        class Agg:
            def __init__(self):
                pass
            def step(self, x):
                pass
            def finalize(self):
                return 17
        try:
            con.create_aggregate("foo", 1, Agg)
            self.fail("Should have raised a ProgrammingError")
        except sqlite.ProgrammingError:
            pass
        except:
            self.fail("Should have raised a ProgrammingError") 
开发者ID:vmware-archive,项目名称:vsphere-storage-for-docker,代码行数:19,代码来源:dbapi.py

示例9: CheckClosed

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import ProgrammingError [as 别名]
def CheckClosed(self):
        con = sqlite.connect(":memory:")
        cur = con.cursor()
        cur.close()

        for method_name in ("execute", "executemany", "executescript", "fetchall", "fetchmany", "fetchone"):
            if method_name in ("execute", "executescript"):
                params = ("select 4 union select 5",)
            elif method_name == "executemany":
                params = ("insert into foo(bar) values (?)", [(3,), (4,)])
            else:
                params = []

            try:
                method = getattr(cur, method_name)

                method(*params)
                self.fail("Should have raised a ProgrammingError: method " + method_name)
            except sqlite.ProgrammingError:
                pass
            except:
                self.fail("Should have raised a ProgrammingError: " + method_name) 
开发者ID:vmware-archive,项目名称:vsphere-storage-for-docker,代码行数:24,代码来源:dbapi.py

示例10: CheckCursorConstructorCallCheck

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import ProgrammingError [as 别名]
def CheckCursorConstructorCallCheck(self):
        """
        Verifies that cursor methods check whether base class __init__ was
        called.
        """
        class Cursor(sqlite.Cursor):
            def __init__(self, con):
                pass

        con = sqlite.connect(":memory:")
        cur = Cursor(con)
        try:
            cur.execute("select 4+5").fetchall()
            self.fail("should have raised ProgrammingError")
        except sqlite.ProgrammingError:
            pass
        except:
            self.fail("should have raised ProgrammingError") 
开发者ID:vmware-archive,项目名称:vsphere-storage-for-docker,代码行数:20,代码来源:regression.py

示例11: CheckRecursiveCursorUse

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import ProgrammingError [as 别名]
def CheckRecursiveCursorUse(self):
        """
        http://bugs.python.org/issue10811

        Recursively using a cursor, such as when reusing it from a generator led to segfaults.
        Now we catch recursive cursor usage and raise a ProgrammingError.
        """
        con = sqlite.connect(":memory:")

        cur = con.cursor()
        cur.execute("create table a (bar)")
        cur.execute("create table b (baz)")

        def foo():
            cur.execute("insert into a (bar) values (?)", (1,))
            yield 1

        with self.assertRaises(sqlite.ProgrammingError):
            cur.executemany("insert into b (baz) values (?)",
                            ((i,) for i in foo())) 
开发者ID:vmware-archive,项目名称:vsphere-storage-for-docker,代码行数:22,代码来源:regression.py

示例12: CheckCursorConstructorCallCheck

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import ProgrammingError [as 别名]
def CheckCursorConstructorCallCheck(self):
        """
        Verifies that cursor methods check whether base class __init__ was
        called.
        """
        class Cursor(sqlite.Cursor):
            def __init__(self, con):
                pass

        con = sqlite.connect(":memory:")
        cur = Cursor(con)
        try:
            cur.execute("select 4+5").fetchall()
            self.fail("should have raised ProgrammingError")
        except sqlite.ProgrammingError:
            pass
        except:
            self.fail("should have raised ProgrammingError")
        with self.assertRaisesRegexp(sqlite.ProgrammingError,
                                     r'^Base Cursor\.__init__ not called\.$'):
            cur.close() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:23,代码来源:regression.py


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