Skip to content
This repository was archived by the owner on Mar 30, 2026. It is now read-only.

Commit 8861a2d

Browse files
authored
add support for tinydb>=4 (#175)
1 parent c202f12 commit 8861a2d

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

pan_cortex_data_lake/adapters/tinydb_adapter.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import os
1111
from threading import RLock
1212

13-
from tinydb import TinyDB, Query
13+
from tinydb import TinyDB, Query, __version__
1414
from tinydb.storages import MemoryStorage
1515

1616
from .. import CortexError
@@ -60,7 +60,12 @@ def init_store(self):
6060
os.makedirs(os.path.dirname(dbfile), 0o700)
6161
except OSError as e:
6262
raise CortexError("{}".format(e))
63-
return TinyDB(dbfile, sort_keys=True, indent=4, default_table="profiles")
63+
if __version__ >= "4.0.0":
64+
db = TinyDB(dbfile, sort_keys=True, indent=4)
65+
db.default_table_name = "profiles"
66+
else:
67+
db = TinyDB(dbfile, sort_keys=True, default_table="profiles", indent=4)
68+
return db
6469

6570
def remove_profile(self, profile=None):
6671
"""Remove profile from credentials file.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ requires-python = ">=3.5"
3838
dynamic = ["version", "description"]
3939
dependencies = [
4040
"requests >=2",
41-
"tinydb >=3,<4"
41+
"tinydb >=3"
4242
]
4343

4444
[project.optional-dependencies]

0 commit comments

Comments
 (0)