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

Uploaded Python 3

File details

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

File metadata

  • Download URL: nevesdb-0.1.4.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.4.tar.gz
Algorithm Hash digest
SHA256 a9156a8c24bbf9b12927f90b12db11ce689fe70180bcf47b2b9ef7a04dfce186
MD5 f7210ef9c04a4c85914fe50fd615f021
BLAKE2b-256 20ccacd2146f0b8d077463a3489ebb10898926e568befcca249cdee78bebda2d

See more details on using hashes here.

Provenance

The following attestation bundles were made for nevesdb-0.1.4.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.4-py3-none-any.whl.

File metadata

  • Download URL: nevesdb-0.1.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 2618ca05de858b58cc5bea128de4239b841cb2e3a87963958ff8824eba279544
MD5 ae7f543e64758a1853ce084e7282a92c
BLAKE2b-256 92030c1879ca812270cd1c6c1e7c55560556c839fa58b40de6c7a76a3d9d5ddb

See more details on using hashes here.

Provenance

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