![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
LightDB is a simple and lightweight JSON database for Python that allows users to efficiently write data to a file. It is designed to be easy to use, making it a great choice for developers who need a fast and reliable way to store and retrieve data
You can install LightDB using pip
:
.. code-block:: bash
pip install LightDB
To use LightDB, first import the LightDB
class from the lightdb
package:
.. code-block:: python
from lightdb import LightDB
Then, create a LightDB
object by passing in the path to a JSON file where the database will be stored:
.. code-block:: python
db = LightDB("db.json")
You can then set key-value pairs in the database using the set()
method:
.. code-block:: python
db.set("name", "Alice")
db.set("age", 30)
To save the changes, use the save()
method:
.. code-block:: python
db.save()
LightDB supports defining models for more structured and convenient data management. Here’s how to use models with LightDB:
First, import the necessary classes:
.. code-block:: python
from typing import List, Dict, Any
from lightdb import LightDB
from lightdb.models import Model
Define your model by extending the Model
class:
.. code-block:: python
class User(Model, table="users"):
name: str
age: int
items: List[str] = []
extra: Dict[str, Any] = {}
Create a new instance of the model and save it to the database:
.. code-block:: python
user = User.create(name="Alice", age=30)
Retrieve a user from the database:
.. code-block:: python
user = User.get(User.name == "Alice")
# or user = User.get(name="Alice")
print(user.name, user.age)
Update a user’s information and save it:
.. code-block:: python
user.name = "Kristy"
user.save()
Filter users based on certain criteria:
.. code-block:: python
users = User.filter(User.age >= 20)
for user in users:
print(user.name)
Delete a user:
.. code-block:: python
user.delete()
FAQs
Lightweight JSON Database for Python
We found that LightDB 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.