Pydantic model support for Django ORM

Overview

Djantic

PyPI version

Documentation: https://jordaneremieff.github.io/djantic/

Requirements: Python 3.7+, Django 2.2+

Pydantic model support for Django.

This project should be considered a work-in-progress. It should be okay to use, but no specific version support has been determined (#16) and the default model generation behaviour may change across releases.

Please use the issues tracker to report any bugs, or if something seems incorrect.

Quickstart

Install using pip:

pip install djantic

Generating schemas from models

Configure a custom ModelSchema class for a Django model to generate a Pydantic model. This will allow using the Django model information with Pydantic model methods:

from users.models import User
from djantic import ModelSchema

class UserSchema(ModelSchema):
    class Config:
        model = User
        
print(UserSchema.schema())

Output:

{
        "title": "UserSchema",
        "description": "A user of the application.",
        "type": "object",
        "properties": {
            "profile": {"title": "Profile", "description": "None", "type": "integer"},
            "id": {"title": "Id", "description": "id", "type": "integer"},
            "first_name": {
                "title": "First Name",
                "description": "first_name",
                "maxLength": 50,
                "type": "string",
            },
            "last_name": {
                "title": "Last Name",
                "description": "last_name",
                "maxLength": 50,
                "type": "string",
            },
            "email": {
                "title": "Email",
                "description": "email",
                "maxLength": 254,
                "type": "string",
            },
            "created_at": {
                "title": "Created At",
                "description": "created_at",
                "type": "string",
                "format": "date-time",
            },
            "updated_at": {
                "title": "Updated At",
                "description": "updated_at",
                "type": "string",
                "format": "date-time",
            },
        },
        "required": ["first_name", "email", "created_at", "updated_at"],
    }

See https://pydantic-docs.helpmanual.io/usage/models/ for more.

Loading and exporting model data

Use the from_django method on a model schema class to load a Django model instance into a schema class:

user = User.objects.create(
    first_name="Jordan", 
    last_name="Eremieff", 
    email="[email protected]"
)

user_schema = UserSchema.from_django(user)
print(user_schema.json(indent=2))

Output:

{
    "profile": null,
    "id": 1,
    "first_name": "Jordan",
    "last_name": "Eremieff",
    "email": "[email protected]",
    "created_at": "2020-08-15T16:50:30.606345+00:00",
    "updated_at": "2020-08-15T16:50:30.606452+00:00"
}

See https://pydantic-docs.helpmanual.io/usage/exporting_models/ for more.

Comments
  • "ValueError: too many values to unpack" with TextChoices

    django==3.0.5
    pydantic==1.8.2
    djantic=0.3.0
    

    Attempting to create a djantic schema for a model that has a django.db.models.TextChoices subclass assigned to a field's choices will result in a ValueError

    For example:

    from django.db import models
    from djantic import ModelSchema
    
    
    class FoodChoices(models.TextChoices):
        BANANA = 'ba', 'A delicious yellow Banana'
        APPLE = 'ap', 'A delicious red Apple'
    
    
    class A(models.Model):
        name = models.CharField(max_length=128)
        preferred_food = models.CharField(max_length=2, choices=FoodChoices.choices)
    
    
    class ASchema(ModelSchema):
        class Config:
            model = A
    

    the above results in:

    ...
    /usr/local/lib/python3.8/site-packages/djantic/main.py in __new__(mcs, name, bases, namespace)
         95 
         96                     else:
    ---> 97                         python_type, pydantic_field = ModelSchemaField(field)
         98 
         99                     field_values[field_name] = (python_type, pydantic_field)
    
    /usr/local/lib/python3.8/site-packages/djantic/fields.py in ModelSchemaField(field)
         85         if field.choices:
         86             enum_choices = {v: k for k, v in field.choices}
    ---> 87             python_type = Enum(  # type: ignore
         88                 f"{field.name.title().replace('_', '')}Enum",
         89                 enum_choices,
    
    /usr/local/lib/python3.8/enum.py in __call__(cls, value, names, module, qualname, type, start)
        339             return cls.__new__(cls, value)
        340         # otherwise, functional API: we're creating a new Enum type
    --> 341         return cls._create_(
        342                 value,
        343                 names,
    
    /usr/local/lib/python3.8/enum.py in _create_(cls, class_name, names, module, qualname, type, start)
        461                 member_name, member_value = item, names[item]
        462             else:
    --> 463                 member_name, member_value = item
        464             classdict[member_name] = member_value
        465         enum_class = metacls.__new__(metacls, class_name, bases, classdict)
    
    ValueError: too many values to unpack (expected 2)
    
    opened by ievans3024 8
  • Fix: case for handling related ManyToMany extraction.

    Fix: case for handling related ManyToMany extraction.

    I had an issue with extraction of reverse ManyToMany relationship, and it seems like there simply was an unhandled case. I didn't really fix anything, I just copied your code from below and thus added another case. I didn't test this code with any automatic tool or unit tests, so beware. I'm rather new to python so feel free to do with it what you want. But please, if you don't pull - take at least the issue into account and do it your way :) I really appreciate your project and it saves our team a lot of time. Thank you.

    opened by AlterEigo 7
  • Fix custom field support and add include_from_annotations.

    Fix custom field support and add include_from_annotations.

    Hi,

    This PR will:

    • Add support to include_from_annotations as shown in README and test_include_from_annotations.
    • Fix the error shown in test_multiple_level_relations where a custom field (user_cache in this example) is present in the Schema.

    Thank you.

    opened by phbernardes 4
  • Add support for: blank and null fields

    Add support for: blank and null fields

    This PR, separated in 2 commits, aims to:

    • Add support for TextChoices fields with blank=True
    • Add support for fields with null=True and default value defined
    opened by phbernardes 4
  • Error on django ImageField

    Error on django ImageField

    Error if I add in scheme field avatar

    Model:

    def get_avatar_upload_path(instance, filename):
        return os.path.join(
            "customer_avatar", str(instance.id), filename)
    
    
    class Customer(models.Model):
        """
        params: user* avatar shop* balance permissions deleted
    
        prefetch: -
        """
        id = models.AutoField(primary_key=True)
        user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='customers', verbose_name='Пользователь')
        avatar = models.ImageField(upload_to=get_avatar_upload_path, verbose_name='Аватарка', blank=True, null=True)
        retail = models.ForeignKey('retail.Retail', on_delete=models.CASCADE, related_name='customers', verbose_name='Розница')
        balance = models.DecimalField(max_digits=9, decimal_places=2, verbose_name='Баланс', default=0)
        permissions = models.ManyToManyField('retail.Permission', verbose_name='Права доступа', related_name='customers', blank=True)
        deleted = models.BooleanField(default=False, verbose_name='Удален')
        created = models.DateTimeField(auto_now_add=True, verbose_name='Дата создания')
    

    Scheme

    class CustomerSchema(ModelSchema):
        user: UserSchema
    
        class Config:
            model = Customer
            include = ['id', 'user', 'avatar', 'retail', 'balance', 'permissions']
    

    Error:

    fastapi_1  | Process SpawnProcess-36:
    fastapi_1  | Traceback (most recent call last):
    fastapi_1  |   File "/usr/local/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
    fastapi_1  |     self.run()
    fastapi_1  |   File "/usr/local/lib/python3.8/multiprocessing/process.py", line 108, in run
    fastapi_1  |     self._target(*self._args, **self._kwargs)
    fastapi_1  |   File "/usr/local/lib/python3.8/site-packages/uvicorn/subprocess.py", line 62, in subprocess_started
    fastapi_1  |     target(sockets=sockets)
    fastapi_1  |   File "/usr/local/lib/python3.8/site-packages/uvicorn/main.py", line 390, in run
    fastapi_1  |     loop.run_until_complete(self.serve(sockets=sockets))
    fastapi_1  |   File "uvloop/loop.pyx", line 1494, in uvloop.loop.Loop.run_until_complete
    fastapi_1  |   File "/usr/local/lib/python3.8/site-packages/uvicorn/main.py", line 397, in serve
    fastapi_1  |     config.load()
    fastapi_1  |   File "/usr/local/lib/python3.8/site-packages/uvicorn/config.py", line 278, in load
    fastapi_1  |     self.loaded_app = import_from_string(self.app)
    fastapi_1  |   File "/usr/local/lib/python3.8/site-packages/uvicorn/importer.py", line 20, in import_from_string
    fastapi_1  |     module = importlib.import_module(module_str)
    fastapi_1  |   File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module
    fastapi_1  |     return _bootstrap._gcd_import(name[level:], package, level)
    fastapi_1  |   File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
    fastapi_1  |   File "<frozen importlib._bootstrap>", line 991, in _find_and_load
    fastapi_1  |   File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
    fastapi_1  |   File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
    fastapi_1  |   File "<frozen importlib._bootstrap_external>", line 783, in exec_module
    fastapi_1  |   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
    fastapi_1  |   File "/opt/project/config/asgi.py", line 18, in <module>
    fastapi_1  |     from backend.retail.fastapp import app
    fastapi_1  |   File "/opt/project/backend/retail/fastapp.py", line 9, in <module>
    fastapi_1  |     from backend.retail.routers import router
    fastapi_1  |   File "/opt/project/backend/retail/routers.py", line 3, in <module>
    fastapi_1  |     from backend.retail.api import auth, postitem, ping, customer
    fastapi_1  |   File "/opt/project/backend/retail/api/customer.py", line 8, in <module>
    fastapi_1  |     from backend.retail.schemas.customer import CustomerSchema
    fastapi_1  |   File "/opt/project/backend/retail/schemas/customer.py", line 7, in <module>
    fastapi_1  |     class CustomerSchema(ModelSchema):
    fastapi_1  |   File "/usr/local/lib/python3.8/site-packages/djantic/main.py", line 97, in __new__
    fastapi_1  |     python_type, pydantic_field = ModelSchemaField(field)
    fastapi_1  |   File "/usr/local/lib/python3.8/site-packages/djantic/fields.py", line 135, in ModelSchemaField
    fastapi_1  |     python_type,
    fastapi_1  | UnboundLocalError: local variable 'python_type' referenced before assignment
    
    opened by 50Bytes-dev 4
  • ValueError: cannot specify both default and default_factory

    ValueError: cannot specify both default and default_factory

    Hello,

    This is a great library. Looking to contribute if you are needing anything done.

    Getting this error but I see it looks fixed in your main branch.

      File "\.venv\lib\site-packages\djantic\main.py", line 102, in __new__
        p_model = create_model(
      File "pydantic\main.py", line 990, in pydantic.main.create_model
      File ".venv\lib\site-packages\djantic\main.py", line 34, in __new__
        cls = super().__new__(mcs, name, bases, namespace)
      File "pydantic\main.py", line 299, in pydantic.main.ModelMetaclass.__new__
      File "pydantic\fields.py", line 403, in pydantic.fields.ModelField.infer
      File "pydantic\fields.py", line 388, in pydantic.fields.ModelField._get_field_info
      File "pydantic\fields.py", line 173, in pydantic.fields.FieldInfo._validate
    ValueError: cannot specify both default and default_factory
    
    Django==3.2.3
    djantic==0.2.0
    pydantic==1.8.2
    

    So just posting this for tracking incase anyone else has the same issue.

    opened by mmcardle 4
  • Simplify from_django by relying in Pydantic. Add multiple level relationship support.

    Simplify from_django by relying in Pydantic. Add multiple level relationship support.

    Hi,

    I open this PR/discussion to:

    • Add support for multiple level relationships (user -> user.orders -> user.orders.order_items -> user.orders.order_items.order_items_details ...)
    • Add support for double underscore aliases (first_name: str = Field(alias="user__first_name")). We can replace it by dot aliases if you prefer (first_name: str = Field(alias="user.first_name"))
    • Simplify from_django logic by relying always that possible in Pydantic, this will increase Djantic performance (reducing serialization time).
    • Fix ManyToMany relations serialization: ManyToMany relations should access related field by related_name or by *_set and should return a list of instances (from a QuerySet) instead of a instance.
    • Harmonize ID/PK usage: instead of returning pk for some fields and id for other, return id for all.
    • Calling XSchema.from_django(xs, many=True) should return a list of XSchema instances instead of a list of dicts.
    • Include GenericForeignKey in schemas.

    Merging this request will cause some breaking changes:

    • ManyToMany relations will return a list of instances instead of a instance. The attribute will be called *_set or the Django's field related_name.
    • ForeignObjectRel will return a list of dicts with pk instead of id: [{'id': 1}] instead of [{'pk': 1}].
    • XSchema.from_django(xs, many=True) will return a list of XSchema instances instead of a list of dicts.

    These changes can be seem in test_relations.py and test_queries.py.

    I din't separated this PR in several commits as these changes are linked, but I can separate it if it's hard to understand.

    Thank you.

    opened by phbernardes 3
  • Use recursive method to correctly handle one_to_many fields

    Use recursive method to correctly handle one_to_many fields

    Given:

    class LabelSchema(ModelSchema):
        class Config:
            model = OrderItemLabel
            include = ['value']
    
    class OrderItemSchema(ModelSchema):
        label: LabelSchema | None
        quantity: int
    
        class Config:
            model = OrderItem
            include = ['label', 'quantity']
    
    class CustomerSchema(ModelSchema):
        class Config:
            model = Customer
            include = ['username']
    
    class OrderSchema(ModelSchema):
        items: list[OrderItemSchema]
        customer: CustomerSchema
        
        class Config:
            model = Order
            include = ['items', 'customer']
    

    When calling:

    OrderSchema.from_django(order).dict()
    

    Will return:

     {
        'items': [
            {'quantity': 1, 'label': None},
            {'quantity': 1, 'label': None},
            {'quantity': 1, 'label': 1}
        ],
        'customer': {'username': '[email protected]'}
    }
    

    Note that label = 1, the ID and not the value (str) expected from LabelSchema.

    With this PR change, the new output is:

    {
        'items': [
            {'quantity': 1, 'label': None},
            {'quantity': 1, 'label': None},
            {'quantity': 1, 'label': {'value': 'Product 10'}}
        ],
         'customer': {'username': '[email protected]'}}
    
    opened by pedro-prose 3
  • Testing djantic for django 3.2

    Testing djantic for django 3.2

    Gave the code a try, went to open a PR for BigAutoField django 3.2 changes, but noticed they were in the main branch already.

    Tried install from pypi 0.2.0 and also looked in the tagged zip and didn't see the changes there.

    updated my requirements.txt

    from

    djantic==0.2.0
    

    to:

    -e git+https://github.com/jordaneremieff/[email protected]#egg=djantic
    

    Was there some other stuff being worked on for django 3.2 support?

    Thanks

    opened by allen-munsch 3
  • Unable to support more than Level 2 relations

    Unable to support more than Level 2 relations

    class Level1(models.Mode): name = models.CharField()

    class Level2(models.Model): parent = models.ForeignKey(Level1) name2 = models.Charge()

    class Level3(models.Model): parent = models.ForeignKey(Level2) name3 = models.Charge()

    class Level3Schema(ModelSchema): name3: str = Field()

    class Level2Schema(ModelSchema): level3_set:List[Level3Schema] = Field(None) name2: str = Field(None)

    class Level1Schema(ModelSchema): level2_set :List[Level2Schema] = Field(None) name1:str = Field(None)

       as following is not work:
     Level1Schema.from_django(level1_instance)
    
    opened by faner-father 3
  • FastAPI + Djantic - OpenAPI spec

    FastAPI + Djantic - OpenAPI spec

    HI,

    First of all, this is a great project, getting a lot of value from it, so thank you.

    Having an issue generating an openapi specification when using it in combination with FastAPI, specifically when using Django model choices.

    Django Model

    from django.db import models
    
    class SimpleModelWithChoices(models.Model):
        class ChoiceType(models.TextChoices):
            CHOICE1 = "CHOICE1"
            CHOICE2 = "CHOICE2"
    
        choice = models.CharField("Type", max_length=30, choices=ChoiceType.choices)
    

    Djantic Spec

    from djantic import ModelSchema
    
    class Schema1(ModelSchema):
        class Config:
            model = SimpleModelWithChoices
    
    
    class Schema2(ModelSchema):
        class Config:
            model = SimpleModelWithChoices
    

    FastAPI

    from fastapi import APIRouter, FastAPI
    
    router = APIRouter()
    application = FastAPI()
    
    @application.get("path1", response_model=Schema1)
    def get1(instance: Schema1):
        return instance
    
    @application.get("path2", response_model=Schema2)
    def get2(instance: Schema2):
        return instance
    
    application.include_router(router)
    
    assert application.openapi()
    

    Error

    .venv\lib\site-packages\fastapi\openapi\utils.py:387: in get_openapi
        definitions = get_model_definitions(
    
        def get_model_definitions(
            flat_models: Set[Union[Type[BaseModel], Type[Enum]]],
            model_name_map: Dict[Union[Type[BaseModel], Type[Enum]], str],
        ) -> Dict[str, Any]:
            definitions: Dict[str, Dict[str, Any]] = {}
            for model in flat_models:
                m_schema, m_definitions, m_nested_models = model_process_schema(
                    model, model_name_map=model_name_map, ref_prefix=REF_PREFIX
                )
                definitions.update(m_definitions)
    >           model_name = model_name_map[model]
    E           KeyError: <enum 'ChoiceEnum'>
    
    .venv\lib\site-packages\fastapi\utils.py:28: KeyError
    

    I think it is due to the way FastAPI keeps a mapping of classes and uses them internally. I have a workaround in my project

    def __fix_enums(new_type):
    
        for item in new_type.__dict__["__fields__"].values():
            if "enum.EnumMeta" in str(item.type_.__class__):
                enum_values = [(i.value, i.value) for i in item.type_]
    
                new_enum_type = Enum(f"{new_type.__name__}_{item.name}_Enum", enum_values, module=__name__)
                setattr(item, "type_", new_enum_type)
    
        return new_type
    

    I would be happy to produce a PR to fix the issue if needed, Maybe adding some sort of uniqueness in the name of the enum class in djantic/fields.py ?

                python_type = Enum(  # type: ignore
                    f"{field.name.title().replace('_', '')}Enum",
                    enum_choices,
                    module=__name__,
                )
    

    Library Versions

    djantic = "^0.3.5"
    Django = "^3.2.5"
    fastapi = "^0.68.0"
    
    opened by mmcardle 2
  • Allow abstract subclasses of ModelSchema

    Allow abstract subclasses of ModelSchema

    Adding the option to implement custom methods in abstract ModelSchema subclasses that cannot be instantiated and thus they don't have to undergo the strict checks that regular ModelSchemata need to fulfill.

    Closes !62

    opened by mikulas-mrva 4
  • Abstract class option for ModelSchema subclasses

    Abstract class option for ModelSchema subclasses

    I am using Djantic in my project, and I would like to base a base class between ModelSchema and my individual model schemata, to implement a to_orm method directly on the ModelSchema, as in my complex case simply doing DjangoModel(**schema) doesn't work because of foreign keys and some other data transformations required. I could just implement it on each of them individually, but then mypy will be very unhappy.

    I would like to be able to do the following:

    class ModelSchemaToORM(ModelSchema):
        # either this, django model style
        class Meta:
            abstract = True
    
        # or this
        class Config:
            abstract = True
    
        async def to_orm(self):
            raise NotImplementedError
    

    Currently the two versions above yield

    pydantic.errors.ConfigError: 'Config' (Is `Config` class defined?)
    

    and

    pydantic.errors.ConfigError: type object 'Config' has no attribute 'model' (Is `Config.model` a valid Django model class?)
    

    respectively.

    Does it make sense to folks here to add an additional condition to ModelSchemaMetaclass to skip Config checks on abstract subclasses? It could either be in Meta or Config, I don't really mind as long as there is a way to put intermediate parents between my ModelSchemata and Djantic's ModelSchema.

    opened by mikulas-mrva 2
  • MyPy support

    MyPy support

    Is MyPy type checking supported at all? Any model property I try to access on a Djantic model is detected as non-existent by mypy. Is this resolvable?

    Maybe I can contribute the solution if someone can point me in the right direction. Thank you.

    help wanted 
    opened by zwx00 1
  • Combine model and schema

    Combine model and schema

    The approach in https://github.com/tiangolo/sqlmodel has me interested exploring a combined model for Django and Pydantic. I would consider doing a PR to that project, though it seems too specific to SQLAlchemy and FastAPI for a Django-specific implementation to be a good fit (also don't know if I'll pursue this at all) - not sure.

    Something like this for the model definition:

    from djantic.models import DjanticModel, Field
    
    class Plant(DjanticModel):
        """A plant."""
    
        common_name: str
        genus_name: str = Field(
            max_length=100,
            help_text="A generic name for a collective group of plants.",
        )
        specific_epithet: str
    
        class Meta:
            ordering = ["genus_name"]
    
        class Config:
            include = ["genus_name", "specific_epithet"]
    

    Then attribute access would (ideally) look like this:

    from myapp.models import Plant
    
    # Schema definition from class
    schema = Plant.schema()
    
    # Export data from instance
    plant = Plant.objects.create(genus_name="Grevillea", specific_epithet="buxifolia")
    data = plant.dict()
    

    Maybe.

    maybe 
    opened by jordaneremieff 1
  • Documentation, docstrings, comments, changelog

    Documentation, docstrings, comments, changelog

    I didn't include any docstrings or comments throughout the project because things were changing quite rapidly, but at this point I should go through and add these. Also a mkdocs gh-page and changelog.

    documentation 
    opened by jordaneremieff 0
Releases(0.7.0)
  • 0.7.0(Apr 14, 2022)

    What's Changed

    • :heavy_plus_sign: Add factory-boy dependency to project. by @jordaneremieff in https://github.com/jordaneremieff/djantic/pull/53
    • Fix custom field support and add include_from_annotations. by @phbernardes in https://github.com/jordaneremieff/djantic/pull/54

    Full Changelog: https://github.com/jordaneremieff/djantic/compare/0.6.0...0.7.0

    Source code(tar.gz)
    Source code(zip)
  • 0.6.0(Mar 26, 2022)

    What's Changed

    • Simplify from_django by relying in Pydantic. Add multiple level relationship support. by @phbernardes in https://github.com/jordaneremieff/djantic/pull/52

    Full Changelog: https://github.com/jordaneremieff/djantic/compare/0.5.0...0.6.0

    Source code(tar.gz)
    Source code(zip)
  • 0.5.0(Mar 3, 2022)

    What's Changed

    • Add tox configuration and test using Python 3.10 by @jordaneremieff in https://github.com/jordaneremieff/djantic/pull/41
    • Bump mkdocs from 1.2.1 to 1.2.3 by @dependabot in https://github.com/jordaneremieff/djantic/pull/43
    • Bump sqlparse from 0.4.1 to 0.4.2 by @dependabot in https://github.com/jordaneremieff/djantic/pull/42
    • Bump django from 3.2.5 to 3.2.12 by @dependabot in https://github.com/jordaneremieff/djantic/pull/48
    • :construction_worker: Run GitHub workflow on pull requests. by @jordaneremieff in https://github.com/jordaneremieff/djantic/pull/50
    • Add support for: blank and null fields by @phbernardes in https://github.com/jordaneremieff/djantic/pull/49

    New Contributors

    • @dependabot made their first contribution in https://github.com/jordaneremieff/djantic/pull/43
    • @phbernardes made their first contribution in https://github.com/jordaneremieff/djantic/pull/49

    Full Changelog: https://github.com/jordaneremieff/djantic/compare/0.4.1...0.5.0

    Source code(tar.gz)
    Source code(zip)
  • 0.4.1(Oct 17, 2021)

  • 0.4.0(Sep 29, 2021)

  • 0.3.5(Aug 20, 2021)

  • 0.3.4(Jul 25, 2021)

  • 0.3.3(Jun 29, 2021)

  • 0.3.2(Jun 29, 2021)

    Publishing workflow had issues on 0.3.1. This is unchanged from that release (https://github.com/jordaneremieff/djantic/releases/tag/0.3.1).

    Source code(tar.gz)
    Source code(zip)
  • 0.3.1(Jun 20, 2021)

    • Add FileField to the string types and cast to string in the export.
    • Add tests for TextChoices and IntegerChoices classes in Django and use enum values for defaults in schema generation.
    Source code(tar.gz)
    Source code(zip)
  • 0.3.0(May 15, 2021)

    • Drop implied support for 2.2 from setup.py and workflows tests.

    • Adjust workflows tests to install from most recent release of minor version.

    • Bugfix providing both default and default factory in Field definiton.

    Source code(tar.gz)
    Source code(zip)
  • 0.2.0(Apr 4, 2021)

  • 0.1.0(Apr 4, 2021)

A curated list of awesome tools for SQLAlchemy

Awesome SQLAlchemy A curated list of awesome extra libraries and resources for SQLAlchemy. Inspired by awesome-python. (See also other awesome lists!)

Hong Minhee (洪 民憙) 2.5k Dec 31, 2022
A PostgreSQL or SQLite orm for Python

Prom An opinionated lightweight orm for PostgreSQL or SQLite. Prom has been used in both single threaded and multi-threaded environments, including en

Jay Marcyes 18 Dec 01, 2022
A very simple CRUD class for SQLModel! ✨

Base SQLModel A very simple CRUD class for SQLModel! ✨ Inspired on: Full Stack FastAPI and PostgreSQL - Base Project Generator FastAPI Microservices I

Marcelo Trylesinski 40 Dec 14, 2022
Rich Python data types for Redis

Created by Stephen McDonald Introduction HOT Redis is a wrapper library for the redis-py client. Rather than calling the Redis commands directly from

Stephen McDonald 281 Nov 10, 2022
SQLModel is a library for interacting with SQL databases from Python code, with Python objects.

SQLModel is a library for interacting with SQL databases from Python code, with Python objects. It is designed to be intuitive, easy to use, highly compatible, and robust.

Sebastián Ramírez 9.1k Dec 31, 2022
MongoEngine flask extension with WTF model forms support

Flask-MongoEngine Info: MongoEngine for Flask web applications. Repository: https://github.com/MongoEngine/flask-mongoengine About Flask-MongoEngine i

MongoEngine 815 Jan 03, 2023
Twisted wrapper for asynchronous PostgreSQL connections

This is txpostgres is a library for accessing a PostgreSQL database from the Twisted framework. It builds upon asynchronous features of the Psycopg da

Jan Urbański 104 Apr 22, 2022
Redis OM Python makes it easy to model Redis data in your Python applications.

Object mapping, and more, for Redis and Python Redis OM Python makes it easy to model Redis data in your Python applications. Redis OM Python | Redis

Redis 568 Jan 02, 2023
Sqlalchemy-databricks - SQLAlchemy dialect for Databricks

sqlalchemy-databricks A SQLAlchemy Dialect for Databricks using the officially s

Flynn 19 Nov 03, 2022
Pydantic model support for Django ORM

Pydantic model support for Django ORM

Jordan Eremieff 318 Jan 03, 2023
Global base classes for Pyramid SQLAlchemy applications.

pyramid_basemodel pyramid_basemodel is a thin, low level package that provides an SQLAlchemy declarative Base and a thread local scoped Session that c

Grzegorz Śliwiński 15 Jan 03, 2023
Sqlalchemy seeder that supports nested relationships.

sqlalchemyseed Sqlalchemy seeder that supports nested relationships. Supported file types json yaml csv Installation Default installation pip install

Jedy Matt Tabasco 10 Aug 13, 2022
A Python Library for Simple Models and Containers Persisted in Redis

Redisco Python Containers and Simple Models for Redis Description Redisco allows you to store objects in Redis. It is inspired by the Ruby library Ohm

sebastien requiem 436 Nov 10, 2022
a small, expressive orm -- supports postgresql, mysql and sqlite

peewee Peewee is a simple and small ORM. It has few (but expressive) concepts, making it easy to learn and intuitive to use. a small, expressive ORM p

Charles Leifer 9.7k Jan 08, 2023
A dataclasses-based ORM framework

dcorm A dataclasses-based ORM framework. [WIP] - Work in progress This framework is currently under development. A first release will be announced in

HOMEINFO - Digitale Informationssysteme GmbH 1 Dec 24, 2021
A database migrations tool for TortoiseORM, ready to production.

Aerich Introduction Aerich is a database migrations tool for Tortoise-ORM, which is like alembic for SQLAlchemy, or like Django ORM with it's own migr

Tortoise 596 Jan 06, 2023
A Python Object-Document-Mapper for working with MongoDB

MongoEngine Info: MongoEngine is an ORM-like layer on top of PyMongo. Repository: https://github.com/MongoEngine/mongoengine Author: Harry Marr (http:

MongoEngine 3.9k Dec 30, 2022
Pony Object Relational Mapper

Downloads Pony Object-Relational Mapper Pony is an advanced object-relational mapper. The most interesting feature of Pony is its ability to write que

3.1k Jan 01, 2023
Adds SQLAlchemy support to Flask

Flask-SQLAlchemy Flask-SQLAlchemy is an extension for Flask that adds support for SQLAlchemy to your application. It aims to simplify using SQLAlchemy

The Pallets Projects 3.9k Jan 09, 2023
A new ORM for Python specially for PostgreSQL

A new ORM for Python specially for PostgreSQL. Fully-typed for any query with Pydantic and auto-model generation, compatible with any sync or async driver

Yan Kurbatov 3 Apr 13, 2022