Skip to main content

Nestipy dababase adapter for edgy

Project description

Nestipy Logo

Version Python License

NestipyDB

NestipyDB is the official database module for Nestipy. It is built on top of Edgy and designed to be modular and configurable.

Installation

NestipyDB depends on Edgy. Make sure to follow the Edgy installation guide to set up dependencies for your specific database.

pip install nestipy-db

Usage

First, in your app_module.py, replace the url in DbConfig with your own:

from nestipy.common import Module
from nestipy_db import DbConfig, DbModule

@Module(
    imports=[
        DbModule.for_root(
            DbConfig(url="sqlite:///db.sqlite", models=[])
        ),
        # other modules...
    ]
)
class AppModule:
    ...

To load the config asynchronously, use DbModule.for_root_async:

from typing import Annotated
from nestipy.common import Module
from nestipy.ioc import Inject
from nestipy_config import ConfigModule, ConfigService, ConfigOption
from nestipy_db import DbConfig, DbModule

async def get_db_config(config: Annotated[ConfigService, Inject()]):
    return DbConfig(
        url=config.get("DATABASE_URL"),
        models=[]
    )

@Module(
    imports=[
        ConfigModule.for_root(ConfigOption(), is_global=True),
        DbModule.for_root_async(
            factory=get_db_config,
            inject=[ConfigService]
        ),
        # other modules...
    ]
)
class AppModule:
    ...

Note

Note that, you need to register all of your models inside DbConfig(..., models=[]) or by importing DbModule.for_feature(Model1, Model2) in your current module.

CLI

NestipyDB aliases Edgy CLI commands and adds support for model generation. Instead of using edgy, use:

nestipy run db #follow edgy command

NestipyDB introduces a new model generation command:

nestipy run db new|g|gen|generate model_name module_name
  • module_name is optional.
  • If omitted, model_name will also be used as the module_name.
  • The model will be created inside the specified module, or the module folder will be created if it doesn't exist.

Support

Nestipy is an MIT-licensed open source project. It continues to grow thanks to support from the community. If you'd like to contribute or sponsor, please [read more here].

Stay in Touch

License

Nestipy is MIT licensed.

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

nestipy_db-0.1.1.tar.gz (74.4 kB view details)

Uploaded Source

Built Distribution

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

nestipy_db-0.1.1-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file nestipy_db-0.1.1.tar.gz.

File metadata

  • Download URL: nestipy_db-0.1.1.tar.gz
  • Upload date:
  • Size: 74.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.21

File hashes

Hashes for nestipy_db-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c36e493b5575ee2073c354da2fad7d0e9178ed27fe0a3b15f840fe4509fa3e9c
MD5 d213fbbd7b58076a0500dbaabdeac49d
BLAKE2b-256 7b6bbb4f8858a17ccb9cdcb71c429a0110b324bb7d5841b0855e54f28091c90c

See more details on using hashes here.

File details

Details for the file nestipy_db-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: nestipy_db-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.21

File hashes

Hashes for nestipy_db-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 744b662c3914c5e21fdc33bbb05cd964efc4589d63ecc7eb0d8033e06bb47435
MD5 3a231661d41e3f9f5d0863b917295c1c
BLAKE2b-256 d32895aa84f42425486f09066e86e2ae9397b6af2d13334e9d500d23e0770040

See more details on using hashes here.

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