Skip to main content

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

nevesdb-0.1.3.tar.gz (16.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nevesdb-0.1.3-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file nevesdb-0.1.3.tar.gz.

File metadata

  • Download URL: nevesdb-0.1.3.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

Hashes for nevesdb-0.1.3.tar.gz
Algorithm Hash digest
SHA256 61cdcc7efb0a2cc6fd3a2886bfc2e2ca16dc19758e6cde6a49df4f125b3210f8
MD5 1b122d52aaa36a31d0a3f97224ee891b
BLAKE2b-256 49053c5496cf7cf66b048ea374fb76872df68e0e1d4dcfd8b938c252faadb90d

See more details on using hashes here.

Provenance

The following attestation bundles were made for nevesdb-0.1.3.tar.gz:

Publisher: python-publish.yml on franklinnevesfilho/NevesDB

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nevesdb-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: nevesdb-0.1.3-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

Hashes for nevesdb-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 32997fe9a986bfb633cdaf03ab384f5264952b3c5b7a33cb35bd972a297b3a9e
MD5 7754baee89b0d25e92cc84c40167f874
BLAKE2b-256 8cb21a9f9b2790b66028097816ee7795cd4aefaaa8b4693ce2b83c533139467d

See more details on using hashes here.

Provenance

The following attestation bundles were made for nevesdb-0.1.3-py3-none-any.whl:

Publisher: python-publish.yml on franklinnevesfilho/NevesDB

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page