beaver-db 0.18.1__py3-none-any.whl → 0.18.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of beaver-db might be problematic. Click here for more details.

beaver/__init__.py CHANGED
@@ -2,4 +2,4 @@ from .core import BeaverDB
2
2
  from .types import Model
3
3
  from .collections import Document, WalkDirection
4
4
 
5
- __version__ = "0.17.6"
5
+ __version__ = "0.18.3"
beaver/core.py CHANGED
@@ -1,5 +1,6 @@
1
1
  import sqlite3
2
2
  import threading
3
+ import warnings
3
4
  from typing import Type
4
5
 
5
6
  from .types import JsonSerializable
@@ -18,7 +19,7 @@ class BeaverDB:
18
19
  This class manages thread-safe database connections and table schemas.
19
20
  """
20
21
 
21
- def __init__(self, db_path: str, timeout:float=30.0):
22
+ def __init__(self, db_path: str, timeout: float = 30.0):
22
23
  """
23
24
  Initializes the database connection and creates all necessary tables.
24
25
 
@@ -39,6 +40,25 @@ class BeaverDB:
39
40
  # connection for the main thread via the `connection` property.
40
41
  self._create_all_tables()
41
42
 
43
+ # check current version against the version stored
44
+ self._check_version()
45
+
46
+ def _check_version(self):
47
+ from beaver import __version__
48
+
49
+ db_version = self.dict("__metadata__").get("version", __version__)
50
+ self.dict("__metadata__")["version"] = db_version
51
+
52
+ if db_version != __version__:
53
+ warnings.warn(
54
+ f"Version mismatch. DB was created with version {db_version}, but the library version is {__version__}.",
55
+ stacklevel=3,
56
+ )
57
+
58
+ @property
59
+ def version(self):
60
+ return self.dict("__metadata__")["version"]
61
+
42
62
  @property
43
63
  def connection(self) -> sqlite3.Connection:
44
64
  """
@@ -49,7 +69,7 @@ class BeaverDB:
49
69
  all subsequent calls within the same thread.
50
70
  """
51
71
  # Check if a connection is already stored for this thread
52
- conn = getattr(self._thread_local, 'conn', None)
72
+ conn = getattr(self._thread_local, "conn", None)
53
73
 
54
74
  if conn is None:
55
75
  # No connection for this thread yet, so create one.
@@ -350,7 +370,9 @@ class BeaverDB:
350
370
 
351
371
  return QueueManager(name, self, model)
352
372
 
353
- def collection[D: Document](self, name: str, model: Type[D] | None = None) -> CollectionManager[D]:
373
+ def collection[D: Document](
374
+ self, name: str, model: Type[D] | None = None
375
+ ) -> CollectionManager[D]:
354
376
  """
355
377
  Returns a singleton CollectionManager instance for interacting with a
356
378
  document collection.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: beaver-db
3
- Version: 0.18.1
3
+ Version: 0.18.3
4
4
  Summary: Fast, embedded, and multi-modal DB based on SQLite for AI-powered applications.
5
5
  License-File: LICENSE
6
6
  Classifier: License :: OSI Approved :: MIT License
@@ -1,9 +1,9 @@
1
- beaver/__init__.py,sha256=QkP3H8ah0QpWqaryT3yjNFX07zjGHMoWgu4dWDHH9eQ,125
1
+ beaver/__init__.py,sha256=89oJ_luJjiKUvw5D0h70YlMbcly60gzp-1gHGMrbYcY,125
2
2
  beaver/blobs.py,sha256=YkIEskHD6oHRaJTF0P25HrTT8LqM-REyV_UBPVQxeqQ,4055
3
3
  beaver/channels.py,sha256=kIuwKMDBdDQObaKT23znsMXzfpKfE7pXSxvf-u4LlpY,9554
4
4
  beaver/cli.py,sha256=Sxm-mYU3LGd4tIqw-5LHb0ektWebjV9vn51hm-CMJD0,2232
5
5
  beaver/collections.py,sha256=CBJSBmJ0LuVI068iRJ2HCXdivxjw51FJOu2BC_54Lfw,24825
6
- beaver/core.py,sha256=68vjuEbkJTHv4SltCLCrgs34BpLCeL602oJZ6CJ34Zo,14560
6
+ beaver/core.py,sha256=d37hnD1xaYdZFKf1z0sDAoGwYwuPU8ETrOotso7aHfk,15209
7
7
  beaver/dicts.py,sha256=Xp8lPfQt08O8zCbptQLWQLO79OxG6uAVER6ryj3SScQ,5495
8
8
  beaver/lists.py,sha256=rfJ8uTNLkMREYc0uGx0z1VKt2m3eR9hvbdvDD58EbmQ,10140
9
9
  beaver/logs.py,sha256=a5xenwl5NZeegIU0dWVEs67lvaHzzw-JRAZtEzNNO3E,9529
@@ -11,8 +11,8 @@ beaver/queues.py,sha256=Fr3oie63EtceSoiC8EOEDSLu1tDI8q2MYLXd8MEeC3g,6476
11
11
  beaver/server.py,sha256=ZYbzcar_xQP3vCgvmrRobIx0L8dfcHtvxRAQNcniJwo,13547
12
12
  beaver/types.py,sha256=WZLINf7hy6zdKdAFQK0EVMSl5vnY_KnrHXNdXgAKuPg,1582
13
13
  beaver/vectors.py,sha256=qvI6RwUOGrhVH5d6PUmI3jKDaoDotMy0iy-bHyvmXks,18496
14
- beaver_db-0.18.1.dist-info/METADATA,sha256=CbtpFh4hUSpVJEegCeRTpATfZeG81Pgybt1ScCyeEz8,21232
15
- beaver_db-0.18.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
- beaver_db-0.18.1.dist-info/entry_points.txt,sha256=bd5E2s45PoBdtdR9-ToKSdLNhmHp8naV1lWP5mOzlrc,42
17
- beaver_db-0.18.1.dist-info/licenses/LICENSE,sha256=1xrIY5JnMk_QDQzsqmVzPIIyCgZAkWCC8kF2Ddo1UT0,1071
18
- beaver_db-0.18.1.dist-info/RECORD,,
14
+ beaver_db-0.18.3.dist-info/METADATA,sha256=5p2CxB2TU1daEjBIXmhbZVwU_arYPRIU16x3azWHe9Q,21232
15
+ beaver_db-0.18.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
+ beaver_db-0.18.3.dist-info/entry_points.txt,sha256=bd5E2s45PoBdtdR9-ToKSdLNhmHp8naV1lWP5mOzlrc,42
17
+ beaver_db-0.18.3.dist-info/licenses/LICENSE,sha256=1xrIY5JnMk_QDQzsqmVzPIIyCgZAkWCC8kF2Ddo1UT0,1071
18
+ beaver_db-0.18.3.dist-info/RECORD,,