A fast, user friendly ORM and query builder which supports asyncio.
MIT License
Bot releases are hidden (Show)
Arrays of Date
/ Time
/ Timestamp
/ Timestamptz
now work in SQLite.
For example:
class MyTable(Table):
times = Array(Time())
dates = Array(Date())
timestamps = Array(Timestamp())
timestamps_tz = Array(Timestamptz())
Published by dantownsend 5 months ago
Added support for a bunch of Postgres functions, like Upper
, Lower
, Length
, and Ltrim
. They can be used in select
queries:
from piccolo.query.functions.string import Upper
>>> await Band.select(Upper(Band.name, alias="name"))
[{"name": "PYTHONISTAS"}]
And also in where
clauses:
>>> await Band.select().where(Upper(Band.manager.name) == 'GUIDO')
[{"name": "Pythonistas"}]
Published by dantownsend 5 months ago
Added an Album
table to the playground, along with some other improvements.
playground/commands/run.py
by @dantownsend in https://github.com/piccolo-orm/piccolo/pull/998
Album
table to playground by @dantownsend in https://github.com/piccolo-orm/piccolo/pull/1000
Fixed a bug with the output(load_json=True)
clause, when used on joined tables.
load_json
on joined tables by @dantownsend in https://github.com/piccolo-orm/piccolo/pull/1002
Published by dantownsend 5 months ago
Fixed a bug with the CLI when reversing migrations (thanks to @metakot for reporting this).
Updated the ASGI templates (thanks to @tarsil for adding Lilya).
Published by dantownsend 7 months ago
Lots of internal improvements, mostly to support new functionality in Piccolo Admin.
array_columns
to Table._meta
by @dantownsend in https://github.com/piccolo-orm/piccolo/pull/954
Array
column for getting the number of dimensions of the array by @dantownsend in https://github.com/piccolo-orm/piccolo/pull/956
where
clauses work in the docs by @dantownsend in https://github.com/piccolo-orm/piccolo/pull/963
Full Changelog: https://github.com/piccolo-orm/piccolo/compare/1.4.2...1.5.0
Published by dantownsend 7 months ago
Improved how ModelBuilder
handles recursive foreign keys.
Published by dantownsend 7 months ago
Fixed an edge case with auto migrations.
If starting from a table like this, with a custom primary key column:
class MyTable(Table):
id = UUID(primary_key=True)
When a foreign key is added to the table which references itself:
class MyTable(Table):
id = UUID(primary_key=True)
fk = ForeignKey("self")
The auto migrations could fail in some situations.
Published by dantownsend 7 months ago
Improved how create_pydantic_model
handles Array
columns:
Array(Array(Integer))
) have more accurate types.Array(Email())
now validates that each item in the list is an email address.Array(Varchar(length=10))
now validates that each item is the correct length (i.e. 10 in this example).Some Pylance errors were fixed in the codebase.
Published by dantownsend 8 months ago
Fixed a bug with nested array columns containing BigInt
. For example:
class MyTable(Table):
my_column = Array(Array(BigInt))
Thanks to @AmazingAkai for reporting this issue.
Published by dantownsend 8 months ago
Fixed a bug with foreign keys which reference BigSerial
primary keys. Thanks to @Abdelhadi92 for reporting this issue.
Published by dantownsend 9 months ago
Added the piccolo user list
command - a quick and convenient way of listing Piccolo Admin users from the command line.
ModelBuilder
now creates timezone aware datetime
objects for Timestamptz
columns.
Updated the ASGI templates.
SQLite auto migrations are now allowed. We used to raise an exception, but now we output a warning instead. While SQLite auto migrations aren't as feature rich as Postgres, they work fine for simple use cases.
Published by dantownsend 10 months ago
There's now an alternative syntax for joins, which works really well with static type checkers like Mypy and Pylance.
The traditional syntax (which continues to work as before):
# Get the band name, and the manager's name from a related table
await Band.select(Band.name, Band.manager.name)
The alternative syntax is as follows:
await Band.select(Band.name, Band.manager._.name)
Note how we use ._.
instead of .
after a ForeignKey
.
This offers a considerably better static typing experience. In the above example, type checkers know that Band.manager._.name
refers to the name
column on the Manager
table. This means typos can be detected, and code navigation is easier.
get_related
.esmerald
ASGI framework.Published by dantownsend 11 months ago
Piccolo allows the user to specify savepoint names which are used in transactions. For example:
async with DB.transaction() as transaction:
await Band.insert(Band(name='Pythonistas'))
# Passing in a savepoint name is optional:
savepoint_1 = await transaction.savepoint('savepoint_1')
await Band.insert(Band(name='Terrible band'))
# Oops, I made a mistake!
await savepoint_1.rollback_to()
Postgres doesn't allow us to parameterise savepoint names, which means there's a small chance of SQL injection, if for some reason the savepoint names were generated from end-user input. Even though the likelihood is very low, it's best to be safe. We now validate the savepoint name, to make sure it can only contain certain safe characters. Thanks to @Skelmis for making this change.
Published by dantownsend 12 months ago
Added support for Python 3.12.
Modified create_pydantic_model
, so additional information is returned in the JSON schema to distinguish between Timestamp
and Timestamptz
columns. This will be used for future Piccolo Admin enhancements.
Published by dantownsend almost 1 year ago
Piccolo v1 is now available!
We migrated to Pydantic v2, and also migrated Piccolo Admin to Vue 3, which puts the project in a good place moving forward.
We don't anticipate any major issues for people who are upgrading. If you encounter any bugs let us know.
Make sure you have v1 of Piccolo, Piccolo API, and Piccolo Admin.
Published by dantownsend almost 1 year ago
Namespaced all custom values we add to Pydantic's JSON schema for easier maintenance.
Published by dantownsend about 1 year ago
Modified the BaseUser.login
logic so all code paths take the same time. Thanks to @Skelmis for this.
Published by dantownsend about 1 year ago
All of the changes from 0.120.0 merged into the v1 branch.
Published by dantownsend about 1 year ago
Improved how ModelBuilder
generates JSON data.
The number of password hash iterations used in BaseUser
has been increased to keep pace with the latest guidance from OWASP - thanks to @Skelmis for this.
Fixed a bug with auto migrations when the table is in a schema (thanks to @lherrman for reporting this).
graphlib
from test coverage by @sinisaos in https://github.com/piccolo-orm/piccolo/pull/874
ModelBuilder
JSON values by @dantownsend in https://github.com/piccolo-orm/piccolo/pull/880
Full Changelog: https://github.com/piccolo-orm/piccolo/compare/0.119.0...0.120.0
Published by dantownsend about 1 year ago
Initial alpha release of Piccolo v1, with Pydantic v2 support (thanks to @sinisaos for helping with this).