beaver-db 0.18.1__tar.gz → 0.18.3__tar.gz
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_db-0.18.1 → beaver_db-0.18.3}/PKG-INFO +1 -1
- {beaver_db-0.18.1 → beaver_db-0.18.3}/beaver/__init__.py +1 -1
- {beaver_db-0.18.1 → beaver_db-0.18.3}/beaver/core.py +25 -3
- {beaver_db-0.18.1 → beaver_db-0.18.3}/pyproject.toml +1 -1
- {beaver_db-0.18.1 → beaver_db-0.18.3}/.dockerignore +0 -0
- {beaver_db-0.18.1 → beaver_db-0.18.3}/.gitignore +0 -0
- {beaver_db-0.18.1 → beaver_db-0.18.3}/.python-version +0 -0
- {beaver_db-0.18.1 → beaver_db-0.18.3}/LICENSE +0 -0
- {beaver_db-0.18.1 → beaver_db-0.18.3}/README.md +0 -0
- {beaver_db-0.18.1 → beaver_db-0.18.3}/beaver/blobs.py +0 -0
- {beaver_db-0.18.1 → beaver_db-0.18.3}/beaver/channels.py +0 -0
- {beaver_db-0.18.1 → beaver_db-0.18.3}/beaver/cli.py +0 -0
- {beaver_db-0.18.1 → beaver_db-0.18.3}/beaver/collections.py +0 -0
- {beaver_db-0.18.1 → beaver_db-0.18.3}/beaver/dicts.py +0 -0
- {beaver_db-0.18.1 → beaver_db-0.18.3}/beaver/lists.py +0 -0
- {beaver_db-0.18.1 → beaver_db-0.18.3}/beaver/logs.py +0 -0
- {beaver_db-0.18.1 → beaver_db-0.18.3}/beaver/queues.py +0 -0
- {beaver_db-0.18.1 → beaver_db-0.18.3}/beaver/server.py +0 -0
- {beaver_db-0.18.1 → beaver_db-0.18.3}/beaver/types.py +0 -0
- {beaver_db-0.18.1 → beaver_db-0.18.3}/beaver/vectors.py +0 -0
- {beaver_db-0.18.1 → beaver_db-0.18.3}/design.md +0 -0
- {beaver_db-0.18.1 → beaver_db-0.18.3}/dockerfile +0 -0
- {beaver_db-0.18.1 → beaver_db-0.18.3}/examples/async_pubsub.py +0 -0
- {beaver_db-0.18.1 → beaver_db-0.18.3}/examples/blobs.py +0 -0
- {beaver_db-0.18.1 → beaver_db-0.18.3}/examples/cache.py +0 -0
- {beaver_db-0.18.1 → beaver_db-0.18.3}/examples/fts.py +0 -0
- {beaver_db-0.18.1 → beaver_db-0.18.3}/examples/fuzzy.py +0 -0
- {beaver_db-0.18.1 → beaver_db-0.18.3}/examples/general_test.py +0 -0
- {beaver_db-0.18.1 → beaver_db-0.18.3}/examples/graph.py +0 -0
- {beaver_db-0.18.1 → beaver_db-0.18.3}/examples/kvstore.py +0 -0
- {beaver_db-0.18.1 → beaver_db-0.18.3}/examples/list.py +0 -0
- {beaver_db-0.18.1 → beaver_db-0.18.3}/examples/logs.py +0 -0
- {beaver_db-0.18.1 → beaver_db-0.18.3}/examples/pqueue.py +0 -0
- {beaver_db-0.18.1 → beaver_db-0.18.3}/examples/producer_consumer.py +0 -0
- {beaver_db-0.18.1 → beaver_db-0.18.3}/examples/publisher.py +0 -0
- {beaver_db-0.18.1 → beaver_db-0.18.3}/examples/pubsub.py +0 -0
- {beaver_db-0.18.1 → beaver_db-0.18.3}/examples/rerank.py +0 -0
- {beaver_db-0.18.1 → beaver_db-0.18.3}/examples/stress_vectors.py +0 -0
- {beaver_db-0.18.1 → beaver_db-0.18.3}/examples/subscriber.py +0 -0
- {beaver_db-0.18.1 → beaver_db-0.18.3}/examples/textual_chat.css +0 -0
- {beaver_db-0.18.1 → beaver_db-0.18.3}/examples/textual_chat.py +0 -0
- {beaver_db-0.18.1 → beaver_db-0.18.3}/examples/type_hints.py +0 -0
- {beaver_db-0.18.1 → beaver_db-0.18.3}/examples/vector.py +0 -0
- {beaver_db-0.18.1 → beaver_db-0.18.3}/makefile +0 -0
- {beaver_db-0.18.1 → beaver_db-0.18.3}/roadmap.md +0 -0
- {beaver_db-0.18.1 → beaver_db-0.18.3}/uv.lock +0 -0
|
@@ -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,
|
|
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](
|
|
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.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|