DEV Community

Cover image for Piccolo, an async query builder and ORM for Python
Daniel Townsend
Daniel Townsend

Posted on

Piccolo, an async query builder and ORM for Python

I'm happy to introduce Piccolo, an async query builder and ORM for Python, which works with Postgres and SQLite.

Some of it's standout features:

Support for asyncio

Asyncio makes a lot of sense when you want high throughput applications. Piccolo is built on top of asyncio and a fast database adapter called asyncpg. You can also use Piccolo within a traditional synchronous app too.

An admin GUI

Most users of Django will tell you that the admin interface is one of its greatest strengths. It saves developers lots of time, compared to building one from scratch for each project. Piccolo has its own admin, which is clean and modern, built using Vue JS.

Piccolo admin GUI

A backend framework

There are thousands of web frameworks out there, but often they just focus on the view layer, and don't think about the database or security.

Piccolo was designed the other way around - focusing on the data layer first, meaning you can use it with any routing library you wish. Piccolo has out of the box support for Starlette and FastAPI. Other ASGI frameworks integrate with Piccolo really easily.

Migrations

No ORM is complete without migrations - Piccolo ships with them right out of the box.

Project templates

Piccolo makes creating a new web app really simple. Just use piccolo asgi new, and a web app template is created for you automatically. Starlette and FastAPI are currently supported.

Playground

Piccolo makes learning the query syntax as easy as possible, using a playground. Use piccolo playground run, and it'll launch an iPython shell, and a test SQLite database, allowing you to practice querying with Piccolo without having to set anything up first.

SQL inspired

Piccolo's syntax for queries is as close as possible to SQL. Anyone with SQL experience should find it very natural to use.

>>> await Movie.select(Movie.name).where(Movie.director.name == 'George Lucas').run()
[{'name': 'Star Wars'}]
Enter fullscreen mode Exit fullscreen mode

Modular code

Piccolo allows you to separate your models into apps, making your code more maintainable, and meaning you can share them with other people on Github, or PyPI.

Security

Piccolo has a bunch of associated middleware, endpoints, and tables to help build a secure web app.

Give it a go!

Give Piccolo a go. It is already being used in production, and is improving at a rapid pace. If you have any feedback or questions, let us know on Github. Thanks!

Top comments (0)