{"id":4338,"library":"apswutils","title":"APSW Utilities","description":"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.","status":"active","version":"0.1.2","language":"en","source_language":"en","source_url":"https://github.com/AnswerDotAI/apswutils","tags":["sqlite","apsw","database","utilities","orm"],"install":[{"cmd":"pip install apswutils","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"apswutils is a wrapper around the apsw SQLite driver; apsw is required for database interaction.","package":"apsw"}],"imports":[{"symbol":"Database","correct":"from apswutils.db import Database"},{"symbol":"Table","correct":"from apswutils.db import Table"},{"symbol":"View","correct":"from apswutils.db import View"},{"symbol":"Queryable","correct":"from apswutils.db import Queryable"},{"note":"The library's README suggests this pattern, stating it only brings in Database, Queryable, Table, View classes without namespace pollution.","symbol":"* (wildcard import)","correct":"from apswutils.db import *"}],"quickstart":{"code":"from apswutils.db import Database, Table\n\ndb = Database(':memory:') # Use ':memory:' for an in-memory database\n\n# Create a table\nusers = Table(db, 'Users')\nusers.create(columns=dict(id=int, name=str, age=int), pk='id')\n\n# Insert data\nusers.insert({'id': 1, 'name': 'Alice', 'age': 30})\nusers.insert_all([\n    {'id': 2, 'name': 'Bob', 'age': 24},\n    {'id': 3, 'name': 'Charlie', 'age': 35}\n])\n\n# Query data\nfor user in users.rows:\n    print(f\"ID: {user['id']}, Name: {user['name']}, Age: {user['age']}\")\n\n# Update table schema (add a column)\nusers.create(columns=dict(id=int, name=str, age=int, email=str), transform=True, pk='id')\nprint(\"\\nUpdated schema:\")\nprint(db.schema)\n\ndb.close()","lang":"python","description":"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."},"warnings":[{"fix":"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.","message":"In version 0.0.3, the `fetchone` method was renamed to `item`. Additionally, `item` now raises an exception if more than one row or field is present in the result.","severity":"breaking","affected_versions":">=0.0.3"},{"fix":"Review your code for any changes in error handling, particularly around `OperationError`, and test thoroughly when upgrading from versions prior to 0.1.0.","message":"Version 0.1.0 introduced breaking changes, though specific details beyond 'Bump version number due to breaking change' are not explicitly documented in the release notes. Subsequent releases indicate the removal of `OperationError` which might be related.","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"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.","message":"The library is built on `apsw`, which has specific behaviors differing from `sqlite3`. `apswutils` defaults to WAL (Write-Ahead Logging) mode. Additionally, `apsw` connections should not be used across `fork` operations (e.g., in `multiprocessing`) unless explicitly closed in the parent before forking.","severity":"gotcha","affected_versions":"All"},{"fix":"Refer to the `sqlite-utils` documentation for in-depth understanding of many underlying concepts and functionalities.","message":"While `apswutils` provides a simplified API, its comprehensive documentation directs users to the `sqlite-utils` project for full details, as `apswutils` is largely a fork with minor changes.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}