ormar | python async orm with fastapi in mind | Object-Relational Mapping library

 by   collerek Python Version: 0.20.1 License: MIT

kandi X-RAY | ormar Summary

kandi X-RAY | ormar Summary

ormar is a Python library typically used in Utilities, Object-Relational Mapping, PostgresSQL, Fastapi applications. ormar has no bugs, it has no vulnerabilities, it has a Permissive License and it has medium support. However ormar build file is not available. You can install using 'pip install ormar' or download it from GitHub, PyPI.

The ormar package is an async mini ORM for Python, with support for Postgres, MySQL, and SQLite.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              ormar has a medium active ecosystem.
              It has 1342 star(s) with 66 fork(s). There are 17 watchers for this library.
              There were 1 major release(s) in the last 6 months.
              There are 57 open issues and 173 have been closed. On average issues are closed in 14 days. There are 21 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of ormar is 0.20.1

            kandi-Quality Quality

              ormar has 0 bugs and 0 code smells.

            kandi-Security Security

              ormar has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              ormar code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              ormar is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              ormar releases are available to install and integrate.
              Deployable package is available in PyPI.
              ormar has no build file. You will be need to create the build yourself to build the component from source.
              Installation instructions, examples and code snippets are available.
              It has 22627 lines of code, 1335 functions and 250 files.
              It has low code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed ormar and discovered the below as its top functions. This is intended to give you an instant insight into ormar implemented functionality, and help decide if they suit your requirements.
            • Define a foreign key constraint
            • Given a to_to_model and a to_to_model and to_to_model
            • Get the database alias
            • Get the column alias
            • Returns a dict representation of the object
            • Return the set of foreign field names
            • Add a set of primary keys to exclude
            • Update exclude with related fields
            • Construct a model instance from a pk value
            • Removes all items from the relation
            • Adds a relationship
            • Prefetch related items
            • Returns the text clause for the filter
            • Adds an item to the relation
            • Get a list of values
            • Return a list of values
            • Persist the model
            • Updates the Forward references field definitions
            • Update the query set according to the given columns
            • Filter the query and return all books
            • Process keyword arguments
            • Create a ManyToMany relationship proxy model
            • Copy data from parent to parent model
            • Read the book
            • Fetch a single result from the query
            • Update the relation
            Get all kandi verified functions for this library.

            ormar Key Features

            No Key Features are available at this moment for ormar.

            ormar Examples and Code Snippets

            Starlite,Minimal Example
            Pythondot img1Lines of Code : 57dot img1License : Permissive (MIT)
            copy iconCopy
            from pydantic import BaseModel, UUID4
            
            
            class User(BaseModel):
                first_name: str
                last_name: str
                id: UUID4
            
            from uuid import UUID
            
            # from pydantic.dataclasses import dataclass
            from dataclasses import dataclass
            
            @dataclass
            class User:
                fir  
            ormar-postgres-extensions,Usage,Fields
            Pythondot img2Lines of Code : 28dot img2License : Permissive (Apache-2.0)
            copy iconCopy
            from uuid import UUID
            
            import ormar
            from ormar_postgres_extensions import PostgresUUID
            
            
            class MyModel(ormar.Model):
                uid: UUID = PostgresUUID(unique=True, nullable=False)
            
            import ormar
            import sqlalchemy
            from ormar_postgres_extensions import Array  
            ormar-postgres-extensions,Installation
            Pythondot img3Lines of Code : 1dot img3License : Permissive (Apache-2.0)
            copy iconCopy
            python -m pip install ormar-postgres-extensions
              
            Switch to test database using FastAPI and ormar
            Pythondot img4Lines of Code : 31dot img4License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            def get_db_uri(self) -> str:
                # set the below in your environment file when running tests
                if self.TESTING:
                    return "sqlite:///../db.sqlite"
            
                if self.PRODUCTION:
                    return self._get_db_uri(
                        user="root",

            Community Discussions

            QUESTION

            Switch to test database using FastAPI and ormar
            Asked 2022-Jan-13 at 15:15

            I am trying ormar with FastAPI and struggling with testing. Because I use Django in the majority of my projects, I am trying to separate my databases between development and testing. But I am struggling to do this.

            The goal is basically, use PostgreSQL for development/production, but switch to SQLite when running pytest. And remove all data from the SQLite database when tests are done.(Imagine Django+Docker dev environment)

            I've tried the following from the ormar documentation, but no luck.

            ...

            ANSWER

            Answered 2022-Jan-12 at 06:42

            I struggled there too. First of all this discussion will help you. Crux here. You need to use an environment variable that points to your sqlite db. I did use BaseSettings from FastAPI and added this method there

            Source https://stackoverflow.com/questions/70558600

            QUESTION

            Alembic migrations in ormar not working (FastAPI)
            Asked 2021-Apr-03 at 15:39

            I want to migrate through Alembic, but something doesn't work. I don't understand what exactly I'm doing wrong.

            My alembic .env

            ...

            ANSWER

            Answered 2021-Apr-03 at 15:39

            The error is caused by usage of declarative_base() from sqlalchemy.

            Sqlalchemy consists of two main parts:

            • ORM - which is a object relational mapping part with Models, relations, queries etc.
            • core - which is much more 'raw' and basic and in general it's related to table and columns creation, as well as queries generation (joins, where clause etc.)

            In ormar only the latter is used and you cannot apply any concept from the ORM part. In fact ormar is kind of (simplified by async and pydantic based) equivalent of the ORM part.

            That means that you cannot inherit from Base <- that's the orm part I mentioned.

            So your sample should look something like following snippets:

            alembic .env

            Source https://stackoverflow.com/questions/66931694

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install ormar

            Note that you can find the same script in examples folder on github.

            Support

            Check out the documentation for details. If you want more real life examples than in the documentation you can see the tests folder, since they actually have to create and connect to a database in most of the tests. Yet remember that those are - well - tests and not all solutions are suitable to be used in real life applications.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            Install
          • PyPI

            pip install ormar

          • CLONE
          • HTTPS

            https://github.com/collerek/ormar.git

          • CLI

            gh repo clone collerek/ormar

          • sshUrl

            git@github.com:collerek/ormar.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Consider Popular Object-Relational Mapping Libraries

            Try Top Libraries by collerek

            sqlalchemy-to-ormar

            by collerekPython

            pydantic-pycharm-plugin

            by collerekKotlin