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.5.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.5-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

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

Hashes for nevesdb-0.1.5.tar.gz
Algorithm Hash digest
SHA256 f032ad6b5e53a4573097e3e11816208a057d78d9932701e3327b038082a501df
MD5 2bba9daaf4b3775e11807488b667730a
BLAKE2b-256 217bc78d02d9e45ba453a75883e2f9856724c91835348f18a0218e87e6e53766

See more details on using hashes here.

Provenance

The following attestation bundles were made for nevesdb-0.1.5.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.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

Hashes for nevesdb-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 b505b9ea118e61359d572e882a2ae89ff006db372a49be58c8fdde674de49f98
MD5 e04eced039875d21bda7f88024a96202
BLAKE2b-256 5a4da43dcb29ffda07719f33edafb47a0e7427a36fc441bdfc72fa7beab61574

See more details on using hashes here.

Provenance

The following attestation bundles were made for nevesdb-0.1.5-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