A simple to use database abstraction layer
Project description
NevesDB
NevesDB is a lightweight, easy-to-use asynchronous database ORM for Python. It simplifies database interactions by providing an intuitive interface for defining models, adding data, and retrieving records.
Features
- Asynchronous support
- Simple model definition
- Easy database initialization
- Automatic table creation
- Built-in CRUD operations
Installation
Ensure you have Python installed. Then, install NevesDB via pip:
pip install nevesdb # Replace with actual package name if different
Usage
1. Initialize the Database
Create an instance of NevesDB and connect to your database:
from nevesdb import NevesDB
# Initialize the database (MySQL example)
db = NevesDB(db_type="mysql", db_user="root", db_password="password", db_name="test_db", db_url="localhost:3306")
2. Define a Model
Models define the structure of your database tables:
from nevesdb import Model
class User(Model):
id: int = 1
name: str = "John Doe"
password: str = "password"
3. Register Models
Register the model to create the corresponding table in the database:
db.register_models([User])
4. Perform CRUD Operations
Add a User
import asyncio
async def add_user(user: User):
await db.add(user)
user1 = User(id=1, name="Alice")
asyncio.run(add_user(user1))
Retrieve a User
async def get_user(user_id: int):
return await db.get(User, {"id": user_id})
users = asyncio.run(get_user(1))
print(users) # [{'id': 1, 'name': 'Alice', 'password': 'password'}]
Running the Example
To run the full example:
async def main():
await add_user(user1)
users = await get_user(1)
print(users)
asyncio.run(main())
License
This project is licensed under the MIT License.
Contributions
Contributions are welcome! Feel free to open an issue or submit a pull request.
Contact
For questions, reach out to the repository maintainers or create an issue.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nevesdb-0.1.5.tar.gz.
File metadata
- Download URL: nevesdb-0.1.5.tar.gz
- Upload date:
- Size: 16.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f032ad6b5e53a4573097e3e11816208a057d78d9932701e3327b038082a501df
|
|
| MD5 |
2bba9daaf4b3775e11807488b667730a
|
|
| BLAKE2b-256 |
217bc78d02d9e45ba453a75883e2f9856724c91835348f18a0218e87e6e53766
|
Provenance
The following attestation bundles were made for nevesdb-0.1.5.tar.gz:
Publisher:
python-publish.yml on franklinnevesfilho/NevesDB
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nevesdb-0.1.5.tar.gz -
Subject digest:
f032ad6b5e53a4573097e3e11816208a057d78d9932701e3327b038082a501df - Sigstore transparency entry: 175212524
- Sigstore integration time:
-
Permalink:
franklinnevesfilho/NevesDB@7ea7545a51f892439c37bb5c566577b79d7b654f -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/franklinnevesfilho
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@7ea7545a51f892439c37bb5c566577b79d7b654f -
Trigger Event:
release
-
Statement type:
File details
Details for the file nevesdb-0.1.5-py3-none-any.whl.
File metadata
- Download URL: nevesdb-0.1.5-py3-none-any.whl
- Upload date:
- Size: 15.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b505b9ea118e61359d572e882a2ae89ff006db372a49be58c8fdde674de49f98
|
|
| MD5 |
e04eced039875d21bda7f88024a96202
|
|
| BLAKE2b-256 |
5a4da43dcb29ffda07719f33edafb47a0e7427a36fc441bdfc72fa7beab61574
|
Provenance
The following attestation bundles were made for nevesdb-0.1.5-py3-none-any.whl:
Publisher:
python-publish.yml on franklinnevesfilho/NevesDB
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nevesdb-0.1.5-py3-none-any.whl -
Subject digest:
b505b9ea118e61359d572e882a2ae89ff006db372a49be58c8fdde674de49f98 - Sigstore transparency entry: 175212525
- Sigstore integration time:
-
Permalink:
franklinnevesfilho/NevesDB@7ea7545a51f892439c37bb5c566577b79d7b654f -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/franklinnevesfilho
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@7ea7545a51f892439c37bb5c566577b79d7b654f -
Trigger Event:
release
-
Statement type: