beaver-db 0.16.5__py3-none-any.whl → 0.16.7__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/channels.py CHANGED
@@ -190,6 +190,16 @@ class ChannelManager[T]:
190
190
 
191
191
  self._listeners.clear()
192
192
 
193
+ def prune(self):
194
+ """
195
+ Cleans the log history for the channel effectively
196
+ deleting all previous logs.
197
+
198
+ Useful for reducing the database once logs are not needed.
199
+ """
200
+ with self._conn:
201
+ self._conn.execute("DELETE FROM beaver_pubsub_log WHERE channel_name = ?", (self._name,))
202
+
193
203
  def _polling_loop(self):
194
204
  """
195
205
  The main loop for the background thread.
beaver/queues.py CHANGED
@@ -25,6 +25,12 @@ class AsyncQueueManager[T]:
25
25
  """Asynchronously adds an item to the queue with a specific priority."""
26
26
  await asyncio.to_thread(self._queue.put, data, priority)
27
27
 
28
+ async def peek(self) -> QueueItem[T] | None:
29
+ """
30
+ Asynchronously returns the first item without removing it, if any, otherwise returns None.
31
+ """
32
+ return await asyncio.to_thread(self._queue.peek)
33
+
28
34
  @overload
29
35
  async def get(self, block: Literal[True] = True, timeout: float | None = None) -> QueueItem[T]: ...
30
36
  @overload
@@ -77,7 +83,7 @@ class QueueManager[T]:
77
83
  (self._name, priority, time.time(), self._serialize(data)),
78
84
  )
79
85
 
80
- def _get_item_atomically(self) -> QueueItem[T] | None:
86
+ def _get_item_atomically(self, pop:bool=True) -> QueueItem[T] | None:
81
87
  """
82
88
  Performs a single, atomic attempt to retrieve and remove the
83
89
  highest-priority item from the queue. Returns None if the queue is empty.
@@ -100,12 +106,21 @@ class QueueManager[T]:
100
106
  return None
101
107
 
102
108
  rowid, priority, timestamp, data = result
103
- cursor.execute("DELETE FROM beaver_priority_queues WHERE rowid = ?", (rowid,))
109
+
110
+ if pop:
111
+ cursor.execute("DELETE FROM beaver_priority_queues WHERE rowid = ?", (rowid,))
104
112
 
105
113
  return QueueItem(
106
114
  priority=priority, timestamp=timestamp, data=self._deserialize(data)
107
115
  )
108
116
 
117
+ def peek(self) -> QueueItem[T] | None:
118
+ """
119
+ Retrieves the first item of the queue.
120
+ If the queue is empy, returns None.
121
+ """
122
+ return self._get_item_atomically(pop=False)
123
+
109
124
  @overload
110
125
  def get(self, block: Literal[True] = True, timeout: float | None = None) -> QueueItem[T]: ...
111
126
  @overload
@@ -1,18 +1,17 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: beaver-db
3
- Version: 0.16.5
3
+ Version: 0.16.7
4
4
  Summary: Fast, embedded, and multi-modal DB based on SQLite for AI-powered applications.
5
- Classifier: Programming Language :: Python :: 3.13
5
+ License-File: LICENSE
6
6
  Classifier: License :: OSI Approved :: MIT License
7
7
  Classifier: Operating System :: OS Independent
8
+ Classifier: Programming Language :: Python :: 3.13
8
9
  Classifier: Topic :: Database
9
10
  Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
10
11
  Requires-Python: >=3.13
11
- Description-Content-Type: text/markdown
12
- License-File: LICENSE
13
12
  Provides-Extra: faiss
14
- Requires-Dist: faiss-cpu>=1.12.0; extra == "faiss"
15
- Dynamic: license-file
13
+ Requires-Dist: faiss-cpu>=1.12.0; extra == 'faiss'
14
+ Description-Content-Type: text/markdown
16
15
 
17
16
  # beaver 🦫
18
17
 
@@ -27,15 +26,17 @@ A fast, single-file, multi-modal database for Python, built with the standard `s
27
26
 
28
27
  `beaver` is the **B**ackend for **E**mbedded, **A**ll-in-one **V**ector, **E**ntity, and **R**elationship storage. It's a simple, local, and embedded database designed to manage complex, modern data types without requiring a database server, built on top of SQLite.
29
28
 
29
+ > If you like beaver's minimalist, no-bullshit philosophy, check out [castor](https://github.com/apiad/castor) for an equally minimalistic approach to task orchestration.
30
+
30
31
  ## Design Philosophy
31
32
 
32
33
  `beaver` is built with a minimalistic philosophy for small, local use cases where a full-blown database server would be overkill.
33
34
 
34
- - **Minimalistic**: Uses only Python's standard libraries (`sqlite3`) and `numpy`/`faiss-cpu`.
35
+ - **Minimalistic**: The core library has zero external dependencies. Vector search capabilities, which require `numpy` and `faiss-cpu`, are available as an optional feature.
35
36
  - **Schemaless**: Flexible data storage without rigid schemas across all modalities.
36
37
  - **Synchronous, Multi-Process, and Thread-Safe**: Designed for simplicity and safety in multi-threaded and multi-process environments.
37
38
  - **Built for Local Applications**: Perfect for local AI tools, RAG prototypes, chatbots, and desktop utilities that need persistent, structured data without network overhead.
38
- - **Fast by Default**: It's built on SQLite, which is famously fast and reliable for local applications. Vector search is accelerated with a high-performance, persistent `faiss` index.
39
+ - **Fast by Default**: It's built on SQLite, which is famously fast and reliable for local applications. Vector search is an optional feature accelerated with a high-performance, persistent `faiss` index.
39
40
  - **Standard Relational Interface**: While `beaver` provides high-level features, you can always use the same SQLite file for normal relational tasks with standard SQL.
40
41
 
41
42
  ## Core Features
@@ -46,7 +47,7 @@ A fast, single-file, multi-modal database for Python, built with the standard `s
46
47
  - **Persistent Priority Queue**: A high-performance, persistent priority queue perfect for task orchestration across multiple processes. Also with optional async support.
47
48
  - **Time-Indexed Log for Monitoring**: A specialized data structure for structured, time-series logs. Query historical data by time range or create a live, aggregated view of the most recent events for real-time dashboards.
48
49
  - **Simple Blob Storage**: A dictionary-like interface for storing medium-sized binary files (like PDFs or images) directly in the database, ensuring transactional integrity with your other data.
49
- - **High-Performance Vector Storage & Search**: Store vector embeddings and perform fast, crash-safe approximate nearest neighbor searches using a `faiss`-based hybrid index.
50
+ - **High-Performance Vector Storage & Search (Optional)**: Store vector embeddings and perform fast approximate nearest neighbor searches using a `faiss`-based hybrid index.
50
51
  - **Full-Text and Fuzzy Search**: Automatically index and search through document metadata using SQLite's powerful FTS5 engine, enhanced with optional fuzzy search for typo-tolerant matching.
51
52
  - **Knowledge Graph**: Create relationships between documents and traverse the graph to find neighbors or perform multi-hop walks.
52
53
  - **Single-File & Portable**: All data is stored in a single SQLite file, making it incredibly easy to move, back up, or embed in your application.
@@ -71,10 +72,18 @@ This hybrid approach allows BeaverDB to provide a vector search experience that
71
72
 
72
73
  ## Installation
73
74
 
75
+ Install the core, dependency-free library:
76
+
74
77
  ```bash
75
78
  pip install beaver-db
76
79
  ```
77
80
 
81
+ If you want vector search capabilities, install the `faiss` extra:
82
+
83
+ ```bash
84
+ pip install "beaver-db[faiss]"
85
+ ```
86
+
78
87
  ## Quickstart
79
88
 
80
89
  Get up and running in 30 seconds. This example showcases a dictionary, a list, and full-text search in a single script.
@@ -1,16 +1,15 @@
1
1
  beaver/__init__.py,sha256=qyEzF1Os7w4b4Hijgz0Y0R4zTrRBrHIGT1mEkZFl2YM,101
2
2
  beaver/blobs.py,sha256=5cmcvlJLY9jaftIRuNbdEryZxI47sw_pYpysYli23NY,3996
3
- beaver/channels.py,sha256=pCO8wFJAHdMzBLKvinI32L_XfU2B91H2qfsj1Tej-bc,9322
3
+ beaver/channels.py,sha256=VBXJDw_be-bSY76kRVzFdMZFoy4CepSMwJACc9NJgpc,9658
4
4
  beaver/collections.py,sha256=860bYpchokjleDIebJaNU1jcGTCMIbg0t4MasEVVbOk,24486
5
5
  beaver/core.py,sha256=t_UzpqcbF2U8BjmQ9aIWTvUzPuVuOLcPzTrZQ2htjn4,13706
6
6
  beaver/dicts.py,sha256=1BQ9A_cMkJ7l5ayWbDG-4Wi3WtQ-9BKd7Wj_CB7dGlU,5410
7
7
  beaver/lists.py,sha256=Q7xjyReBWFg47nBrXbt09GvBJkEmXvpW9ptL9xCnXC8,9946
8
8
  beaver/logs.py,sha256=mlJizZU0emlqLwuNeBJSPlict35Vyi35L4eIl5orv-M,9673
9
- beaver/queues.py,sha256=IQoeNhcYrVZTuH_4bWhtiEa-EYbFx_2iVKkR254XPnE,5953
9
+ beaver/queues.py,sha256=rhzP-4PMNaYRH60lQu0a4cSUyOtJdN6TR82m61JBsuU,6434
10
10
  beaver/types.py,sha256=bR1bfLgemcySy9mnVL_hxAtog4wN8EmgfF2OonOWjQA,1464
11
11
  beaver/vectors.py,sha256=grwiRdusa39s-J9c8nK8LO7duhuYTaLR2Az6wHKs4rU,18487
12
- beaver_db-0.16.5.dist-info/licenses/LICENSE,sha256=1xrIY5JnMk_QDQzsqmVzPIIyCgZAkWCC8kF2Ddo1UT0,1071
13
- beaver_db-0.16.5.dist-info/METADATA,sha256=DmwvY96CusqfzVY0mwC0eOMGz6eYhQ_29YPWt75vhEA,17836
14
- beaver_db-0.16.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
15
- beaver_db-0.16.5.dist-info/top_level.txt,sha256=FxA4XnX5Qm5VudEXCduFriqi4dQmDWpQ64d7g69VQKI,7
16
- beaver_db-0.16.5.dist-info/RECORD,,
12
+ beaver_db-0.16.7.dist-info/METADATA,sha256=iFdXZPm8ayklLq4fzO9RgamVszerQSeDWSEyR28gMcg,18240
13
+ beaver_db-0.16.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
14
+ beaver_db-0.16.7.dist-info/licenses/LICENSE,sha256=1xrIY5JnMk_QDQzsqmVzPIIyCgZAkWCC8kF2Ddo1UT0,1071
15
+ beaver_db-0.16.7.dist-info/RECORD,,
@@ -1,5 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.9.0)
2
+ Generator: hatchling 1.27.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
-
@@ -1 +0,0 @@
1
- beaver