Skip to content

Commit

Permalink
Merge pull request #10 from iterative/execute-debug
Browse files Browse the repository at this point in the history
sqltrie: sqlite: add sqlite version check
  • Loading branch information
efiop authored Mar 10, 2023
2 parents f3d1e5b + da5a90f commit 7f99053
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/sqltrie/sqlite/sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

from ..trie import AbstractTrie, Change, ShortKeyError, TrieKey, TrieNode, TrieStep

# https://www.sqlite.org/lang_UPSERT.html
MIN_SQLITE_VER = (3, 24, 0)

# NOTE: seems like "named" doesn't work without changing this global var,
# so unfortunately we have to stick with qmark.
assert sqlite3.paramstyle == "qmark"
Expand Down Expand Up @@ -65,6 +68,11 @@ def rollback(self):

@property
def _conn(self): # pylint: disable=method-hidden
if sqlite3.sqlite_version_info < MIN_SQLITE_VER:
raise RuntimeError(
f"SQLite version is too old, please upgrade to >= {MIN_SQLITE_VER}"
)

conn = getattr(self._local, "conn", None)
if conn is None:
conn = self._local.conn = sqlite3.connect(self._path)
Expand Down

0 comments on commit 7f99053

Please sign in to comment.