4 ms·
My sqlite-utils CLI tool and Python library includes a workaround for SQLite's ALTER TABLE limitations. The transform CLI command (and Python method) automates
by simonw 5y ago
My sqlite-utils CLI tool and Python library includes a workaround for SQLite's ALTER TABLE limitations.
The transform CLI command (and Python method) automates the process of starting a transaction, creating a new table with the required changes, copying across the data from the old table, then dropping the old and renaming the new before committing the transaction.
Documentation here:
- Python library: https://sqlite-utils.datasette.io/en/stable/python-api.html#transforming-a-table https://sqlite-utils.datasette.io/en/stable/python-api.html#...
- CLI command: https://sqlite-utils.datasette.io/en/stable/cli.html#transforming-tables https://sqlite-utils.datasette.io/en/stable/cli.html#transfo...
- Blog entry: https://simonwillison.net/2020/Sep/23/sqlite-advanced-alter-table/ https://simonwillison.net/2020/Sep/23/sqlite-advanced-alter-...