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.1

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.1
File Size Uploaded
mayim-1.4.1.tar.gz 41.8 kB Details

Built distribution (wheel)

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

Total release size: 85.0 kB

Release files / mayim-1.4.1.tar.gz

Download URL mayim-1.4.1.tar.gz
Size 41.8 kB
Tags Source
SHA-256 checksum
How to use checksums
2aada1c0c5f5a9d6bec7a09146da9b354542e123196b2f93ec87a4accb95a20b
BLAKE2b-256 checksum
How to use checksums
819e27ebc90d4cb80de29b3ac0227e5dca436af6adb29bb28cbe2da04d266a21
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.1-py3-none-any.whl

Download URL mayim-1.4.1-py3-none-any.whl
Size 43.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9e5aaffb5b30ab60b56e00c77b675b52e354f6ea91a323dc5fa89959e73cf261
BLAKE2b-256 checksum
How to use checksums
29954cd26f4864daa57959c8319057ef611d935e142b87e4258ee88bed5625c9
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

1.4.2

2 release files

This release

1.4.1 This release

2 release files

1.4.0

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