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


Python sqlite3.sqlite_version_info方法代码示例

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


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

示例1: sqlite_check

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import sqlite_version_info [as 别名]
def sqlite_check(app_configs, **kwargs):
    errors = []
    if 'sqlite' not in settings.DATABASES['default']['ENGINE']:
        # not using sqlite, so don't worry
        return errors

    import sqlite3
    if sqlite3.sqlite_version_info < (3, 12):
        errors.append(
            Warning(
                'SQLite version problem',
                hint='A bug is sqlite version 3.11.x causes a segfault in our tests. Upgrading to >=3.14 is suggested. This is only a warning because many things still work. Just not the tests.',
                id='coredata.E001',
            )
        )
    return errors 
开发者ID:sfu-fas,项目名称:coursys,代码行数:18,代码来源:apps.py

示例2: CheckLocking

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import sqlite_version_info [as 别名]
def CheckLocking(self):
        """
        This tests the improved concurrency with pysqlite 2.3.4. You needed
        to roll back con2 before you could commit con1.
        """
        if sqlite.sqlite_version_info < (3, 2, 2):
            # This will fail (hang) on earlier versions of sqlite.
            # Determine exact version it was fixed. 3.2.1 hangs.
            return
        self.cur1.execute("create table test(i)")
        self.cur1.execute("insert into test(i) values (5)")
        try:
            self.cur2.execute("insert into test(i) values (5)")
            self.fail("should have raised an OperationalError")
        except sqlite.OperationalError:
            pass
        except:
            self.fail("should have raised an OperationalError")
        # NO self.con2.rollback() HERE!!!
        self.con1.commit() 
开发者ID:vmware-archive,项目名称:vsphere-storage-for-docker,代码行数:22,代码来源:transactions.py

示例3: create

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import sqlite_version_info [as 别名]
def create(self):
        for schema_name, mapping in self.mappings.iteritems():
            self.db_cursor.execute('drop table if exists %s' % schema_name)
            slversion = sqlite3.sqlite_version_info[:3]
            if slversion > (3, 8, 0):
                self.db_cursor.execute(
                    '''CREATE VIRTUAL TABLE %s USING fts4(id, %s, prefix="3,5,7", %s);''' %
                    (schema_name,
                     ','.join(mapping['fields']),
                     ','.join(mapping['notindexed']))
                )
            elif slversion > (3, 7, 7):
                print "Warning: older version of sqlite3 detected, please upgrade to sqlite 3.8.0 or newer."
                self.db_cursor.execute(
                    '''CREATE VIRTUAL TABLE %s USING fts4(id, %s, prefix="3,5,7");''' %
                    (schema_name,
                     ','.join(mapping['fields']))
                )
            else:
                raise ImportError('Your version of sqlite3 is too old, please upgrade to sqlite 3.8.0 or newer.') 
开发者ID:Net-ng,项目名称:kansha,代码行数:22,代码来源:sqliteengine.py

示例4: test_purge_deleted_rows_old

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import sqlite_version_info [as 别名]
def test_purge_deleted_rows_old(self):
        dialect = self.engine.url.get_dialect()
        if dialect == sqlite.dialect:
            # We're seeing issues with foreign key support in SQLite 3.6.20
            # SQLAlchemy doesn't support it at all with < SQLite 3.6.19
            # It works fine in SQLite 3.7.
            # Force foreign_key checking if running SQLite >= 3.7
            import sqlite3
            tup = sqlite3.sqlite_version_info
            if tup[0] > 3 or (tup[0] == 3 and tup[1] >= 7):
                self.conn.execute("PRAGMA foreign_keys = ON")
        # Purge at 30 days old, should only delete 2 rows
        db.purge_deleted_rows(self.context, age_in_days=30)
        plans_rows = self.session.query(self.plans).count()
        resources_rows = self.session.query(self.resources).count()
        # Verify that we only deleted 2
        self.assertEqual(4, plans_rows)
        self.assertEqual(4, resources_rows) 
开发者ID:openstack,项目名称:karbor,代码行数:20,代码来源:test_purge.py

示例5: test_purge_deleted_rows_older

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import sqlite_version_info [as 别名]
def test_purge_deleted_rows_older(self):
        dialect = self.engine.url.get_dialect()
        if dialect == sqlite.dialect:
            # We're seeing issues with foreign key support in SQLite 3.6.20
            # SQLAlchemy doesn't support it at all with < SQLite 3.6.19
            # It works fine in SQLite 3.7.
            # Force foreign_key checking if running SQLite >= 3.7
            import sqlite3
            tup = sqlite3.sqlite_version_info
            if tup[0] > 3 or (tup[0] == 3 and tup[1] >= 7):
                self.conn.execute("PRAGMA foreign_keys = ON")
        # Purge at 10 days old now, should delete 2 more rows
        db.purge_deleted_rows(self.context, age_in_days=10)

        plans_rows = self.session.query(self.plans).count()
        resources_rows = self.session.query(self.resources).count()
        # Verify that we only have 2 rows now
        self.assertEqual(2, plans_rows)
        self.assertEqual(2, resources_rows) 
开发者ID:openstack,项目名称:karbor,代码行数:21,代码来源:test_purge.py

示例6: CheckRaiseTimeout

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import sqlite_version_info [as 别名]
def CheckRaiseTimeout(self):
        if sqlite.sqlite_version_info < (3, 2, 2):
            # This will fail (hang) on earlier versions of sqlite.
            # Determine exact version it was fixed. 3.2.1 hangs.
            return
        self.cur1.execute("create table test(i)")
        self.cur1.execute("insert into test(i) values (5)")
        try:
            self.cur2.execute("insert into test(i) values (5)")
            self.fail("should have raised an OperationalError")
        except sqlite.OperationalError:
            pass
        except:
            self.fail("should have raised an OperationalError") 
开发者ID:vmware-archive,项目名称:vsphere-storage-for-docker,代码行数:16,代码来源:transactions.py

示例7: CheckOnConflictRollback

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import sqlite_version_info [as 别名]
def CheckOnConflictRollback(self):
        if sqlite.sqlite_version_info < (3, 2, 2):
            return
        con = sqlite.connect(":memory:")
        con.execute("create table foo(x, unique(x) on conflict rollback)")
        con.execute("insert into foo(x) values (1)")
        try:
            con.execute("insert into foo(x) values (1)")
        except sqlite.DatabaseError:
            pass
        con.execute("insert into foo(x) values (2)")
        try:
            con.commit()
        except sqlite.OperationalError:
            self.fail("pysqlite knew nothing about the implicit ROLLBACK") 
开发者ID:vmware-archive,项目名称:vsphere-storage-for-docker,代码行数:17,代码来源:regression.py

示例8: CheckSqlTimestamp

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import sqlite_version_info [as 别名]
def CheckSqlTimestamp(self):
        # The date functions are only available in SQLite version 3.1 or later
        if sqlite.sqlite_version_info < (3, 1):
            return

        # SQLite's current_timestamp uses UTC time, while datetime.datetime.now() uses local time.
        now = datetime.datetime.now()
        self.cur.execute("insert into test(ts) values (current_timestamp)")
        self.cur.execute("select ts from test")
        ts = self.cur.fetchone()[0]
        self.assertEqual(type(ts), datetime.datetime)
        self.assertEqual(ts.year, now.year) 
开发者ID:vmware-archive,项目名称:vsphere-storage-for-docker,代码行数:14,代码来源:types.py

示例9: CheckSqlTimestamp

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import sqlite_version_info [as 别名]
def CheckSqlTimestamp(self):
        # The date functions are only available in SQLite version 3.1 or later
        if sqlite.sqlite_version_info < (3, 1):
            return

        now = datetime.datetime.utcnow()
        self.cur.execute("insert into test(ts) values (current_timestamp)")
        self.cur.execute("select ts from test")
        ts = self.cur.fetchone()[0]
        self.assertEqual(type(ts), datetime.datetime)
        self.assertEqual(ts.year, now.year) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:13,代码来源:types.py

示例10: CheckOpenUri

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import sqlite_version_info [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)') 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:15,代码来源:dbapi.py

示例11: test_bad_target_in_transaction

# 需要导入模块: import sqlite3 [as 别名]
# 或者: from sqlite3 import sqlite_version_info [as 别名]
def test_bad_target_in_transaction(self):
        bck = sqlite.connect(':memory:')
        bck.execute('CREATE TABLE bar (key INTEGER)')
        bck.executemany('INSERT INTO bar (key) VALUES (?)', [(3,), (4,)])
        with self.assertRaises(sqlite.OperationalError) as cm:
            self.cx.backup(bck)
        if sqlite.sqlite_version_info < (3, 8, 8):
            self.assertEqual(str(cm.exception), 'target is in transaction') 
开发者ID:CedricGuillemet,项目名称:Imogen,代码行数:10,代码来源:backup.py


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