Skip to main content

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.

Release files for mayim 1.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mayim 1.4.0
File Size Uploaded
mayim-1.4.0.tar.gz 40.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mayim 1.4.0
File Interpreter ABI Platform
mayim-1.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 83.6 kB

Release files / mayim-1.4.0.tar.gz

Download URL mayim-1.4.0.tar.gz
Size 40.9 kB
Tags Source
SHA-256 checksum
How to use checksums
64fdb00eb67d1211be3a6e02b5dd1381c59170933b78dfaa10a3d78dcc614a33
BLAKE2b-256 checksum
How to use checksums
47e625f37f0fc2d7e9b6004022e9bfbb6ffb43fedd809f1dfe924046d5ddf8fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / mayim-1.4.0-py3-none-any.whl

Download URL mayim-1.4.0-py3-none-any.whl
Size 42.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
795ddd9877864e01c53c982dc0a37a106c486239f0369a7462c3466883ed973a
BLAKE2b-256 checksum
How to use checksums
6aef8f11d8b3787230931d408722c1d2a2910ea05ed9febf4c6d2b0e9ca71a97
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

1.4.0 This release

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.3.0

2 release files

0.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page