Fastlite provides quality-of-life improvements for interactive use of the `sqlite-utils` library, particularly in Jupyter environments. It enhances database and table access with auto-completion, simplifies dataclass creation from schemas, and streamlines data manipulation. The library is currently active, with version 0.2.4 addressing recent bug fixes and continuing to evolve with new usability features.
pip install fastliteVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize an in-memory SQLite database, create a table with a primary key, insert new records, and retrieve data. It covers basic table creation, insertion, and querying using Fastlite's simplified `db.t` table access.
Migrate calls from `fetchone` to `selectone`. If your code expects multiple rows or handles non-unique results, adjust logic to catch `RowCountError` or use alternative querying methods like `table()` for a list of results.
Ensure `apsw` is installed (`pip install apsw`). Code that directly interacted with `sqlite3` specifics or relied on its exact concurrency model might need review, although Fastlite aims to abstract most of these differences.
When querying or inserting, be mindful of this distinction. Use `WHERE column IS NULL` for `None` values and `WHERE column = ''` for empty strings in SQL queries, and ensure your Python data correctly reflects this semantic difference.
Upgrade to version 0.2.4 or newer to ensure `insert(..., ignore=True)` behaves as expected and gracefully handles duplicate keys without raising a `KeyError`.
Run `pip install fastlite` to install the library.
When working with views, use direct SQL queries or standard Pythonic filtering on the results instead of the `.xtra()` method.
If your query might return multiple rows, use `table()` to retrieve a list of results, or adjust your query to ensure it returns at most one row.
Upgrade fastlite to version 0.2.4 or newer by running `pip install --upgrade fastlite` to ensure `insert(..., ignore=True)` handles duplicate keys gracefully.