apswutils (version 0.1.2) is a Python utility library that forks sqlite-minutils to provide a convenient API for interacting with SQLite databases using the `apsw` driver. It offers simplified methods for database and table creation, data insertion, and querying, essentially acting as a lightweight wrapper over `apsw`. The project is actively maintained with recent updates and emphasizes features like WAL mode by default.
pip install apswutilsVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize an in-memory SQLite database, create a table with defined columns and a primary key, insert single and multiple records, and query all rows. It also shows how to modify the table schema by adding a new column.
Replace calls to `fetchone()` with `item()`. Ensure that `item()` is only used when exactly one row and field are expected, or wrap in a try-except block.
Review your code for any changes in error handling, particularly around `OperationError`, and test thoroughly when upgrading from versions prior to 0.1.0.
Be aware of `apsw`'s unique characteristics. If using `multiprocessing`, ensure `apsw` database connections are closed in the parent process before new processes are spawned. Explicitly manage transactions if not relying on `apsw`'s default autocommit behavior for non-transactional statements.
Refer to the `sqlite-utils` documentation for in-depth understanding of many underlying concepts and functionalities.
Install the 'apsw' module using pip: 'pip install apsw'.
Ensure 'apsw' is installed correctly and rename any local files named 'apsw.py' to avoid conflicts.
Use the 'apsw' module instead, which provides this functionality: 'import apsw; connection = apsw.Connection("database.db"); connection.enable_load_extension(True)'.Run `pip install apswutils` to install the library.
Import the necessary classes directly from the `apswutils.db` submodule, for example: `from apswutils.db import Database, Table` or `from apswutils.db import *`.