Skip to main content

The NOT ORM hydrator

Project description

Mayim

The NOT ORM Python hydrator

What is Mayim?

The simplest way to describe it would be to call it a one-way ORM. That is to say that it does not craft SQL statements for you. Think of it as BYOQ (Bring Your Own Query).

Why?

I have nothing against ORMs, truthfully. They serve a great purpose and can be the right tool for the job in many situations. I just prefer not to use them where possible. Instead, I would rather have control of my SQL statements.

The typical tradeoff though is that there is more work needed to hydrate from SQL queries to objects. Mayim aims to solve that.

Getting Started

pip install mayim[postgres]
import asyncio
from typing import List
from mayim import Mayim, PostgresExecutor, sql
from dataclasses import dataclass

@dataclass
class Person:
    name: str

class PersonExecutor(PostgresExecutor):
    @sql("SELECT * FROM people LIMIT $limit OFFSET $offset")
    async def select_all_people(
        self, limit: int = 4, offset: int = 0
    ) -> List[Person]:
        ...

async def run():
    executor = PersonExecutor()
    Mayim(dsn="postgres://...")
    print(await executor.select_all_people())


asyncio.run(run())

Documentation

The docs: ahopkins.github.io/mayim

Framework support

Out of the box, Mayim comes with extensions to support Quart, Sanic, and Starlette applications. Checkout the docs for more info.

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

mayim-1.1.0.tar.gz (20.7 kB view details)

Uploaded Source

Built Distribution

mayim-1.1.0-py3-none-any.whl (30.3 kB view details)

Uploaded Python 3

File details

Details for the file mayim-1.1.0.tar.gz.

File metadata

  • Download URL: mayim-1.1.0.tar.gz
  • Upload date:
  • Size: 20.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for mayim-1.1.0.tar.gz
Algorithm Hash digest
SHA256 43c002dda52b584c6931841f56690181e75e97b0316fdf533d82f1d964e7ce29
MD5 88efd5b86fef326d0dff9899f841ae1f
BLAKE2b-256 2fcf142038eb1ff39d76bf35692e7057b1f47864edd3e042992b01464053de02

See more details on using hashes here.

File details

Details for the file mayim-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: mayim-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 30.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for mayim-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 918bfca7d7b34d7957127576fa0701b1517b5eeefb1f0183f3561b510d1bcc62
MD5 1fe9739eb75db75622e94a7e5d17831d
BLAKE2b-256 462271ef50447d7b8e9ae12de4f4f2187ec49883faed7b38e3f457dcd71a544e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page