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.0.tar.gz (9.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.0-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nevesdb-0.1.0.tar.gz
  • Upload date:
  • Size: 9.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.0.tar.gz
Algorithm Hash digest
SHA256 4c507cb9f254fb2012ee135e8113565c6e1b445731d5f526f70cd70feb30cb35
MD5 cf22db15fe0ab54eb2d11110b010bdd8
BLAKE2b-256 c359ec07a9a0d312d723461c7524505499ebe47838e0cc5431bb3c102d4b6bef

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: nevesdb-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.8 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2b52c55dbe94ead123953a35151eb18029600b20128b7e8a3b5e19d5263eef4e
MD5 0cf82f0afc2fa2650ee5902b33c50ea9
BLAKE2b-256 45a478f321338095ede4ea25a9f8670395c2cb4b08eefad34965929621301b89

See more details on using hashes here.

Provenance

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