Piccolo

A fast, user friendly ORM and query builder which supports asyncio. Read the docs.

Features

Some of it’s stand out features are:

  • Support for sync and async.
  • A builtin playground, which makes learning a breeze.
  • Tab completion support - works great with iPython and VSCode.
  • Batteries included - a User model, authentication, migrations, an admin GUI, and more.
  • Modern Python - fully type annotated.

Syntax

The syntax is clean and expressive.

You can use it as a query builder:

# Select:
await Band.select(
    Band.name
).where(
    Band.popularity > 100
).run()

# Join:
await Band.select(
    Band.name,
    Band.manager.name
).run()

# Delete:
await Band.delete().where(
    Band.popularity < 1000
).run()

# Update:
await Band.update({Band.popularity: 10000}).where(
    Band.name == 'Pythonistas'
).run()

Or like a typical ORM:

# To create a new object:
b = Band(name='C-Sharps', popularity=100)
await b.save().run()

# To fetch an object from the database, and update it:
b = await Band.objects().where(Band.name == 'Pythonistas').first().run()
b.popularity = 10000
await b.save().run()

# To delete:
await b.remove().run()

Installation

Installing with PostgreSQL driver:

pip install piccolo[postgres]

Installing with SQLite driver:

pip install piccolo[sqlite]

Building a web app?

Let Piccolo scaffold you an ASGI web app, using Piccolo as the ORM:

piccolo asgi new

GitHub

https://github.com/piccolo-orm/piccolo