Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
PetDB is a simple and lightweight NOSQL JSON database for pet projects. It was designed with the convenient and comfortable mongo-like API. In this package also was implemented simple array with the same API, that supports not only dict documents but any built-in python type.
PetDB can be installed with pip:
python -m pip install petdb
You can also download the project source and do:
pip install .
PetDB was created as a lightweight package, so there are no dependencies.
To use this database you should only import PetDB and get an instance. By default, it will create folder for storing collections in the current directory, but you can provide any path:
from petdb import PetDB
db = PetDB.get(os.path.join(os.getcwd(), "persistent", "storage"))
Next you should select the collection, if it doesn't exist, it will created automatically. You can do it just by attribute access, by index key or use a method (it will create a new one if it doesn't exist):
users = db.users
subscriptions = db["subscriptions"]
payments = db.collection("payments")
>>> from petdb import PetDB
>>> db = PetDB.get()
>>> users = db["users"]
>>> users.insert_many([
... {"name": "John", "age": 28, "subscriptions": ["tv", "cloud"]},
... {"name": "Michael", "age": 32, "subscriptions": ["tv"]},
... {"name": "Sam", "age": 18, "subscriptions": ["music", "cloud"]},
... {"name": "Alex", "age": 24, "subscriptions": ["tv", "music"]},
... {"name": "Bob", "age": 18, "subscriptions": ["music"]},
... ])
[{"name": "John", "age": 28, "subscriptions": ["tv", "cloud"], "_id": "..."}, ...]
>>> users.update(
... {"$append": {"subscriptions": "games"}},
... {"age": {"$lt": 25}, "subscriptions": {"$contains": "music"}}
... )
>>> selection = users.filter({"age": 18}).sort("name")
>>> print(selection.pick("name").list())
["Bob", "Sam"]
>>> selection.remove()
[{"name": "Bob", "age": 18, "subscriptions": ["music", "games"], "_id": "..."},
{"name": "Sam", "age": 18, "subscriptions": ["music", "cloud", "games"], "_id": "..."}]
>>> for user in users:
... print(user)
...
{'name': 'John', 'age': 28, 'subscriptions': ['tv', 'cloud'], '_id': '...'}
{'name': 'Michael', 'age': 32, 'subscriptions': ['tv'], '_id': '...'}
{'name': 'Alex', 'age': 24, 'subscriptions': ['tv', 'music', 'games'], '_id': '...'}
Documentation is available at https://petdb.readthedocs.io/en/latest/
python -m tests
FAQs
Light weight local document-oriented database
We found that petdb 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.