當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。