Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update zimply.py #37

Closed
wants to merge 1 commit into from
Closed

Update zimply.py #37

wants to merge 1 commit into from

Conversation

aeryskyB
Copy link

@aeryskyB aeryskyB commented Jan 3, 2024

Addresses the issue regarding disabled fts4 in recent sqlite3 versions.
Updates (minimal) the syntax to be consistent with fts5.

Addresses the disabled fts4 (fts5 enabled by default) problem by updating to the fts5 syntax (fixes kimbauters#36)
@kimbauters
Copy link
Owner

This specific fix would only work if you have FTS5, which isn't a guarantee for older installs. This is handled more carefully in the version2 branch by testing/checking for the highest supported FTS version and adapting the app accordingly:

ZIMply/zimply/zim_core.py

Lines 1429 to 1453 in 237364d

def _highest_fts_level():
# test FTS support in SQLite3; return True, False, or None when only available when loading extension
def verify_fts_level(level):
# try to create an FTS table using an in-memory DB, or try to explicitly load the extension
tmp_db = sqlite3.connect(":memory:")
try:
tmp_db.execute("CREATE VIRTUAL TABLE capability USING fts" + str(level) + "(title);")
except sqlite3.Error:
try:
tmp_db.enable_load_extension(True)
tmp_db.load_extension("fts" + str(level))
except sqlite3.Error:
return False
return None
finally:
tmp_db.close()
return True
if verify_fts_level(5) is True:
return 5
if verify_fts_level(4) is True:
return 4
if verify_fts_level(3) is True:
return 3
return None
.

Either the version2 branch needs to be (finally) mainlined – which still requires work to update the server for Python2 support, e.g. using https://github.com/chai-project/chai-backend-api/blob/f4df68ef0ae9e859e891949ec012faa220029f1e/chai_api/main.py#L21-L28 as well as an update to the html interface. Alternatively, this more advanced handling of FTS needs to be backported to the older main branch.

@aeryskyB
Copy link
Author

aeryskyB commented Jan 3, 2024

@kimbauters,
I see your concern.
However, if any new user (who I suppose will use python3) goes for pip install zimply, I think, will face the same issue.

Best!

@kimbauters kimbauters closed this Feb 14, 2024
@aeryskyB aeryskyB deleted the patch-1 branch February 14, 2024 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error while index creation during first time server start-up
2 participants