Piccolo · a fast async ORM for Python

3 months ago

Meet Piccolo: a modern, async ORM for Python. Most Python ORMs give you a way to query your database and stop there. Piccolo goes further. One command scaffolds a whole web app, with a REST API and a polished admin panel over your data. Batteries included, the way Django does it, but async and fully typed.

Ask

Ask about this presentation

Answers are generated from this presentation.

Chapters

  1. 0:00Piccolo
  2. 0:18A modern async ORM, batteries included
  3. 0:40Clean, expressive queries
  4. 0:55One command scaffolds the whole app
  5. 1:14Create the tables, add a login
  6. 1:33Then open the admin
  7. 1:52From nothing to a running admin
Show transcript

Piccolo

A fast, async ORM for Python, with the batteries included.

pip install → piccolo asgi new → a running admin

Meet Piccolo: a modern, async ORM for Python. Most Python ORMs give you a way to query your database and stop there. Piccolo goes further. One command scaffolds a whole web app, with a REST API and a polished admin panel over your data. Batteries included, the way Django does it, but async and fully typed.

A modern async ORM, batteries included

  • Fully typed · real autocomplete, mistakes caught early.
  • Async first · and synchronous when you want it.
  • Batteries · migrations, auth, apps, and an admin.

So what is Piccolo? A fast query builder and ORM for Python. It's fully type annotated, so you get real autocomplete and your editor catches mistakes before you run anything. It's async first, and works synchronously when you want. And it's batteries included: migrations, a user model with authentication, Django style apps, and the admin. MIT, and open source.

Clean, expressive queries

# query-builder style
await Band.select(Band.name).where(Band.popularity > 100)

# or classic ORM objects
band = Band(name="Pythonistas")
await band.save()

Try queries live with piccolo playground run.

The query syntax reads like Python. Select a column, filter it with a where clause, and await the result. Or work with objects: build a row, then save it. Same tables, two styles. You can even try queries in an interactive playground before you write any project code.

One command scaffolds the whole app

pip install 'piccolo[all]'

piccolo asgi new
#  Which routing framework?  → fastapi
#  Which server?             → uvicorn

Generates an example Task table, a REST API, and an admin mounted at /admin/.

Here's the batteries included part. Install Piccolo with all its extras, then run piccolo asgi new. It asks which routing framework, pick FastAPI, and which server, pick uvicorn. In one step it scaffolds a complete web app: an example Task table, a REST API over it, and, in the command's own words, an admin, already mounted at slash admin.

Create the tables, add a login

piccolo migrations new home --auto   # autogenerate
piccolo migrations forwards all      # apply them

piccolo user create                  # an admin login

Two commands wire up the database. piccolo migrations new home, with dash dash auto, inspects your tables and writes the migration for you. piccolo migrations forwards all applies it, creating your Task table plus the tables the admin needs. Automatic migrations, nothing written by hand. Then piccolo user create adds an admin login for the panel.

Then open the admin

python main.py  →  localhost:8000/admin/

Piccolo Admin, a web GUI over your tables

Filtering, CSV export, dark mode, bulk actions, media, and more.

Now run it. python main dot py starts the server. Open localhost, slash admin, and there it is: a polished web admin over your data. Filtering, CSV export, dark mode, bulk actions, media, even multi factor authentication, all for free. The docs call it the crown jewel of the Piccolo ecosystem.

From nothing to a running admin

  • A few commands · pip install to a REST API + admin.
  • Included · migrations, auth, and apps.
  • Your framework · FastAPI, Starlette, Litestar, more.
  • Yours · fully typed, async, MIT.

piccolo-orm.readthedocs.io

That's the whole arc. From pip install to a running REST API and an admin over your data, in a handful of commands, with migrations, authentication, and your choice of web framework, all included. Fully typed, async, and MIT licensed. Start here: piccolo orm dot readthedocs dot io.