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.3.0.tar.gz (37.3 kB view details)

Uploaded Source

Built Distribution

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

mayim-1.3.0-py3-none-any.whl (39.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mayim-1.3.0.tar.gz
  • Upload date:
  • Size: 37.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mayim-1.3.0.tar.gz
Algorithm Hash digest
SHA256 fe755d0c74f2581c29d63dc22f3a58b177a0de90e3a6f0b5eddb35f4d0c31ed6
MD5 06ffc32bc504ddffa3aba19766706f8c
BLAKE2b-256 6e7c17b538442746653db774b9f1b0c845f884d35b7940cd88977bf205bf57ca

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mayim-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 39.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mayim-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e4a09ed5b2667ecc96f56a69610c1446ee86763c355f3e0bef76e335e92f6d5d
MD5 df0b28965b6ab868ee778da0c35b1b51
BLAKE2b-256 9d0e54c4e4a1afd92bff0329283b1de1f1a6e094a74d51c647dc2c7d8c247a45

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