Releases: piccolo-orm/piccolo
0.54.0
Added the db_column_name
option to columns. This is for edge cases where a legacy database is being used, with problematic column names. For example, if a column is called class
, this clashes with a Python builtin, so the following isn't possible:
class MyTable(Table):
class = Varchar() # Syntax error!
You can now do the following:
class MyTable(Table):
class_ = Varchar(db_column_name='class')
Here are some example queries using it:
# Create - both work as expected
MyTable(class_='Test').save().run_sync()
MyTable.objects().create(class_='Test').run_sync()
# Objects
row = MyTable.objects().first().where(MyTable.class_ == 'Test').run_sync()
>>> row.class_
'Test'
# Select
>>> MyTable.select().first().where(MyTable.class_ == 'Test').run_sync()
{'id': 1, 'class': 'Test'}
0.53.0
An internal code clean up (courtesy @yezz123).
Dramatically improved CLI appearance when running migrations (courtesy @wmshort).
Added a runtime reflection feature, where Table
classes can be generated on the fly from existing database tables (courtesy @AliSayyah). This is useful when dealing with very dynamic databases, where tables are frequently being added / modified, so hard coding them in a tables.py
file is impractical. Also, for exploring databases on the command line. It currently just supports Postgres.
Here's an example:
from piccolo.table_reflection import TableStorage
storage = TableStorage()
Band = await storage.get_table('band')
>>> await Band.select().run()
[{'id': 1, 'name': 'Pythonistas', 'manager': 1}, ...]
0.52.0
Lots of improvements to piccolo schema generate
:
- Dramatically improved performance, by executing more queries in parallel (courtesy @AliSayyah).
- If a table in the database has a foreign key to a table in another schema, this will now work (courtesy @AliSayyah).
- The column defaults are now extracted from the database (courtesy @wmshort).
- The
scale
andprecision
values forNumeric
/Decimal
column types are extracted from the database (courtesy @wmshort). - The
ON DELETE
andON UPDATE
values forForeignKey
columns are now extracted from the database (courtesy @wmshort).
Added BigSerial
column type (courtesy @aliereno).
Added GitHub issue templates (courtesy @AbhijithGanesh).
0.51.1
0.51.0
0.50.0
There are lots of great improvements in this release:
where
clause changes
The where
clause can now accept multiple arguments (courtesy @AliSayyah):
Concert.select().where(
Concert.venue.name == 'Royal Albert Hall',
Concert.band_1.name == 'Pythonistas'
).run_sync()
It's another way of expressing AND
. It's equivalent to both of these:
Concert.select().where(
Concert.venue.name == 'Royal Albert Hall'
).where(
Concert.band_1.name == 'Pythonistas'
).run_sync()
Concert.select().where(
(Concert.venue.name == 'Royal Albert Hall') & (Concert.band_1.name == 'Pythonistas')
).run_sync()
create
method
Added a create
method, which is an easier way of creating objects (courtesy @AliSayyah).
# This still works:
band = Band(name="C-Sharps", popularity=100)
band.save().run_sync()
# But now we can do it in a single line using `create`:
band = Band.objects().create(name="C-Sharps", popularity=100).run_sync()
piccolo schema generate
bug fix
Fixed a bug with piccolo schema generate
where columns with unrecognised column types were omitted from the output (courtesy @AliSayyah).
--trace
docs
Added docs for the --trace
argument, which can be used with Piccolo commands to get a traceback if the command fails (courtesy @hipertracker).
DoublePrecision
column type
Added DoublePrecision
column type, which is similar to Real
in that it stores float
values. However, those values are stored with greater precision (courtesy @AliSayyah).
AppRegistry
improvements
Improved AppRegistry
, so if a user only adds the app name (e.g. blog
), instead of blog.piccolo_app
, it will now emit a warning, and will try to import blog.piccolo_app
(courtesy @aliereno).
0.49.0
Fixed a bug with create_pydantic_model
when used with a Decimal
/ Numeric
column when no digits
arguments was set (courtesy @AliSayyah).
Added the create_tables
function, which accepts a sequence of Table
subclasses, then sorts them based on their ForeignKey
columns, and creates them. This is really useful for people who aren't using migrations (for example, when using Piccolo in a simple data science script). Courtesy @AliSayyah.
from piccolo.tables import create_tables
create_tables(Band, Manager, if_not_exists=True)
# Equivalent to:
Manager.create_table(if_not_exists=True).run_sync()
Band.create_table(if_not_exists=True).run_sync()
Fixed typos with the new fixtures app - sometimes it was referred to as fixture
and other times fixtures
. It's now standardised as fixtures
(courtesy @hipertracker).
0.48.0
The piccolo user create
command can now be used without using the interactive prompt, by passing in command line arguments instead (courtesy @AliSayyah).
For example piccolo user create --username=bob ...
.
This is useful when you want to create users in a script.
0.47.0
You can now use pip install piccolo[all]
, which will install all optional requirements.
0.46.0
Added the fixtures app. This is used to dump data from a database to a JSON file, and then reload it again. It's useful for seeding a database with essential data, whether that's a colleague setting up their local environment, or deploying to production.
To create a fixture:
piccolo fixtures dump --apps=blog > fixture.json
To load a fixture:
piccolo fixtures load fixture.json
As part of this change, Piccolo's Pydantic support was brought into this library (prior to this it only existed within the piccolo_api
library). At a later date, the piccolo_api
library will be updated, so it's Pydantic code just proxies to what's within the main piccolo
library.