Skip to main content

A production-grade Python Prisma client

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

Prismaa

A Python Prisma client backed by SQLAlchemy — no Node.js or Rust at runtime.

Prismaa reads a standard schema.prisma file and generates a fully-typed async Python client. All queries run through SQLAlchemy Core — SQLite, PostgreSQL, and any other SQLAlchemy dialect work out of the box.

db = Prisma()
await db.connect("sqlite+aiosqlite:///dev.db")

alice = await db.user.create(data={"email": "alice@example.com", "name": "Alice"})

posts = await db.post.find_many(
    where={"author": {"email": "alice@example.com"}, "published": True},
    include={"author": True},
    order={"createdAt": "desc"},
)

await db.disconnect()

Why Prismaa?

The original prisma-client-py is no longer maintained and requires a Rust query engine and a Node.js subprocess at every query. Prismaa replaces that with a pure-Python SQLAlchemy layer — the Prisma CLI is only used during development to manage migrations, never at runtime.

prisma-client-py Prismaa
Runtime dependency Rust engine + Node.js None
Query layer Prisma Query Engine SQLAlchemy Core
Schema format Prisma schema Prisma schema
Async support Yes Yes
Type safety Yes Yes (Pydantic v2)

Features

  • Pure Python runtime — no Node.js process, no Rust binary, no subprocess at query time
  • Async-first — every method is async; built for asyncio
  • Fully typed — Pydantic v2 models, TypedDict query inputs, typed relation attributes
  • Prisma v7 schema — use the standard schema format and the official Prisma CLI for migrations
  • SQLAlchemy backend — JOIN-based relation filtering, correlated EXISTS subqueries, connection pooling
  • Rich query API — filtering, ordering, pagination (offset and cursor), distinct, include, select, transactions, raw queries, group_by aggregations

Installation

pip install prismaa

For PostgreSQL:

pip install "prismaa[postgresql]"

Prismaa uses the Prisma CLI (a Node.js tool) for schema migrations. It is only needed during development — see Prisma CLI Setup for a one-time setup guide.


Quick start

1. Write a schema

# schema.prisma

generator client {
  provider  = "prismaa"
  output    = "./prisma"
  interface = "asyncio"
}

datasource db {
  provider = "sqlite"
}

model User {
  id    Int    @id @default(autoincrement())
  email String @unique
  name  String
  posts Post[]
}

model Post {
  id        Int     @id @default(autoincrement())
  title     String
  content   String
  published Boolean @default(false)
  authorId  Int
  author    User    @relation(fields: [authorId], references: [id])
}

2. Push the schema and generate the client

# Push schema to the database (creates tables)
npx prisma db push --url "file:./dev.db"

# Generate the Python client
prismaa generate --schema schema.prisma

3. Use it

import asyncio
from prisma import Prisma

async def main():
    db = Prisma()
    await db.connect("sqlite+aiosqlite:///dev.db")

    # Create a user
    alice = await db.user.create(
        data={"email": "alice@example.com", "name": "Alice"}
    )

    # Create a post linked to that user
    post = await db.post.create(
        data={"title": "Hello world", "content": "My first post.", "authorId": alice.id},
        include={"author": True},
    )
    print(post.author.name)  # Alice

    # Filter posts through a related model
    posts = await db.post.find_many(
        where={"author": {"email": "alice@example.com"}},
        include={"author": True},
        order={"title": "asc"},
    )

    # Update
    await db.post.update(
        where={"id": post.id},
        data={"published": True},
    )

    # Count
    n = await db.post.count(where={"published": True})
    print(f"{n} published post(s)")

    # Delete
    await db.post.delete(where={"id": post.id})

    await db.disconnect()

asyncio.run(main())

Database support

Database Driver Install
SQLite aiosqlite included
PostgreSQL asyncpg pip install "prismaa[postgresql]"
Any SQLAlchemy dialect bring your own pass the URL to connect()

Documentation

Full documentation: xlaszlo.github.io/prismaa


Contributing

Found a bug or have a feature idea? Please open an issue on GitHub Issues with a minimal reproducible description of the problem or feature. Please do not open pull requests — a clear issue description is more useful than a PR without prior discussion.

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

prismaa-0.1.4.tar.gz (136.7 kB view details)

Uploaded Source

Built Distribution

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

prismaa-0.1.4-py3-none-any.whl (30.6 kB view details)

Uploaded Python 3

File details

Details for the file prismaa-0.1.4.tar.gz.

File metadata

  • Download URL: prismaa-0.1.4.tar.gz
  • Upload date:
  • Size: 136.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for prismaa-0.1.4.tar.gz
Algorithm Hash digest
SHA256 963236785f50aad331c861988f31ca434ae82370deb4c6901e961376b5d9c5ec
MD5 058401e60c253a7fa48cb6f30e7a9304
BLAKE2b-256 3e89818c50fd81e8e8a6ab1ed8443239ea6315078c486090b4604d93718d834e

See more details on using hashes here.

Provenance

The following attestation bundles were made for prismaa-0.1.4.tar.gz:

Publisher: release.yml on xLaszlo/prismaa

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file prismaa-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: prismaa-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 30.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for prismaa-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 54bdeb4212530573003f977a83e3a2a17cebded7612b0b287abe8761ee1aa50e
MD5 ac5b74826551b3fa5bf828adb0a4e08d
BLAKE2b-256 c2fcb55f69a862337471dc63eba1f80e85f142865dda063da026d22a3f3aee79

See more details on using hashes here.

Provenance

The following attestation bundles were made for prismaa-0.1.4-py3-none-any.whl:

Publisher: release.yml on xLaszlo/prismaa

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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