def fts5_installed(cls): # Test in-memory DB to determine if the FTS5 extension is installed. tmp_db = sqlite3.connect(':memory:') try: tmp_db.execute('CREATE VIRTUAL TABLE fts5test USING fts5 (data);') except: try: sqlite3.enable_load_extension(True) sqlite3.load_extension('fts5') except: return False else: cls._meta.database.load_extension('fts5') finally: tmp_db.close() return True
def check_fts5(): tmp_db = SqliteExtDatabase(':memory:') class FTS5Test(FTS5Model): data = BareField(null=True) class Meta: database = tmp_db try: FTS5Test.create_table() except: try: sqlite3.enable_load_extension(True) sqlite3.load_extension('fts5') except: return False finally: tmp_db.close() return True
def check_fts5(): tmp_db = database_initializer.get_in_memory_database() class FTS5Test(FTS5Model): data = BareField(null=True) class Meta: database = tmp_db try: FTS5Test.create_table() except OperationalError: try: sqlite3.enable_load_extension(True) sqlite3.load_extension('fts5') except OperationalError: return False finally: tmp_db.close() return True