mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-24 09:54:31 +02:00
db.sqlite_version property and fix for deterministic=True on SQLite 3.8.3
Closes #408
This commit is contained in:
parent
521921b849
commit
d25cdd37a3
4 changed files with 47 additions and 3 deletions
|
|
@ -387,7 +387,11 @@ class Database:
|
|||
if not replace and (name, arity) in self._registered_functions:
|
||||
return fn
|
||||
kwargs = {}
|
||||
if deterministic and sys.version_info >= (3, 8):
|
||||
if (
|
||||
deterministic
|
||||
and sys.version_info >= (3, 8)
|
||||
and self.sqlite_version >= (3, 8, 3)
|
||||
):
|
||||
kwargs["deterministic"] = True
|
||||
self.conn.create_function(name, arity, fn, **kwargs)
|
||||
self._registered_functions.add((name, arity))
|
||||
|
|
@ -547,6 +551,12 @@ class Database:
|
|||
except Exception:
|
||||
return False
|
||||
|
||||
@property
|
||||
def sqlite_version(self) -> Tuple[int, ...]:
|
||||
"Version of SQLite, as a tuple of integers e.g. (3, 36, 0)"
|
||||
row = self.execute("select sqlite_version()").fetchall()[0]
|
||||
return tuple(map(int, row[0].split(".")))
|
||||
|
||||
@property
|
||||
def journal_mode(self) -> str:
|
||||
"Current ``journal_mode`` of this database."
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue