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

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.2
File Size Uploaded
mayim-1.4.2.tar.gz 43.0 kB Details

Built distribution (wheel)

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

Total release size: 87.2 kB

Release files / mayim-1.4.2.tar.gz

Download URL mayim-1.4.2.tar.gz
Size 43.0 kB
Tags Source
SHA-256 checksum
How to use checksums
24611e2bca3548efe177c8f54e07c770c267fda44757d765dfe4bc1039526bd1
BLAKE2b-256 checksum
How to use checksums
15d9bae4efd314ac78412908b79ee79e3b86f77d98c47d8b10d1fe0d47293cdd
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.2-py3-none-any.whl

Download URL mayim-1.4.2-py3-none-any.whl
Size 44.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ba5e7411bcdd3126247cd5db8c6877004a9a9ad7c8ec7a61c98e86b26a3c60ed
BLAKE2b-256 checksum
How to use checksums
4f2fcc01a83acd5006c9704f8458aa165b8749c69e189cc2707d94db7b35c15e
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.2 This release

2 release files

1.4.1

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