
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Bison is a fast, lightweight NoSQL database, written in Rust with seamless Python bindings.
Bison is a fast, lightweight NoSQL database, written in Rust with seamless Python bindings. It combines the speed and safety of Rust with the flexibility of JSON storage, offering a MongoDB-like query language to easily store, query, and manipulate your data. Perfect for developers who need a powerful, schema-less database that integrates smoothly into Python projects, Bison is designed to handle complex queries and efficient updates while keeping your data operations simple and intuitive.
$eq
, $ne
, $gt
, $gte
, $lt
, $lte
for filtering documents.$set
, $inc
, $dec
, $add
, $substract
, and $delete
operators.db.write()
or db.write_all()
.To use Bison in your Python project, install it using:
pip install bison-db
I decided to compare Bison against TinyDB as it is the most similar database to Bison in terms of purpose. In our performance benchmarks, Bison is around 2-13x faster than TinyDB (depending on the type of operations and number of documents). The chart shows the median time to execute 1000 operations on a database with 1000 collections. Each update triggers a write to file in both Bison and TinyDB.
pytest -k comparison
from bison import Bison
db = Bison()
# Create a collection
db.create_collection("test")
# Insert documents
db.insert("test", {"a": 10, "b": 20})
db.insert("test", {"a": True, "b": False})
# Simple equality query
result = db.find("test", {"a": 10})
print(result) # Returns documents where field 'a' equals 10
# Query with greater than operator
result = db.find("test", {"a": {"$gt": 5}})
print(result) # Returns documents where 'a' is greater than 5
You can update documents only when a filter query is matched. If no filter query is provided, all documents in the collection will be updated.
# Conditionally update documents where 'a' equals 10
db.update("test", {"b": {"$set": 30}}, {"a": {"$eq": 10}})
# Update all documents in the collection if no filter is provided
db.update("test", {"b": {"$set": 50}}, None)
By default, Bison stores all updates in memory. Changes will only be committed to a file when you explicitly call db.write(collection_name)
for a specific collection, or db.write_all()
to write all collections to disk:
# Commit changes of a specific collection to disk
db.write("test")
# Commit changes of all collections to disk
db.write_all()
# Update document by setting a new value
db.update("test", {"a": {"$set": 30}})
# Increment a field
db.update("test", {"a": {"$inc": ""}})
# Decrement a field
db.update("test", {"a": {"$dec": ""}})
# Delete a field from a document
db.update("test", {"a": {"$delete": ""}})
Bison supports a range of MongoDB-like query operators:
$eq
: Matches values that are equal to a specified value.
$ne
: Matches all values that are not equal to a specified value.
$gt
: Matches values that are greater than a specified value.
$gte
: Matches values that are greater than or equal to a specified value.
$lt
: Matches values that are less than a specified value.
$lte
: Matches values that are less than or equal to a specified value.
# Equality
result = db.find("test", {"a": {"$eq": 10}})
# Not equal
result = db.find("test", {"a": {"$ne": 20}})
# Greater than
result = db.find("test", {"a": {"$gt": 10}})
# Less than
result = db.find("test", {"a": {"$lt": 100}})
Bison provides several operators for updating fields within documents:
$set
: Sets the value of a field.
$inc
: Increments a field by 1.
$dec
: Decrements a field by 1.
$add
: Adds a specified value to a field.
$substract
: Subtracts a specified value from a field.
$delete
: Deletes a field from a document.
# Set a value
db.update("test", {"a": {"$set": 40}})
# Increment a field
db.update("test", {"b": {"$inc": ""}})
# Delete a field
db.update("test", {"a": {"$delete": ""}})
You can combine multiple query conditions, including nested fields:
# Query with mixed conditions
result = db.find(
"test",
{
"a": {"nested_field": {"myobj": 20}},
"b": {"$gt": 19},
"c.nested_field.really_nested": {"$lte": 120}
}
)
print(result) # Returns documents matching all the conditions
Invalid queries will raise exceptions. For example:
from bison import Bison
import pytest
db = Bison()
# Insert a document
db.insert("test", {"a": 10})
# Invalid query
with pytest.raises(ValueError):
db.find("test", {"a": {"$gt": False}})
FAQs
Bison is a fast, lightweight NoSQL database, written in Rust with seamless Python bindings.
We found that bison-db demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.