gws.lib.sqlitex

Convenience wrapper for the SA SQLite engine.

This wrapper accepts a database path and optionally an “init” DDL statement. It executes queries given in a text form.

Failed queries are repeated up to 3 times to work around transient errors, like the DB being locked.

If the error message is “no such table”, the wrapper runs the “init” DDL before repeating.

Source code: gws.lib.sqlitex

Package Contents

exception gws.lib.sqlitex.Error

Bases: gws.Error

GWS error.

class gws.lib.sqlitex.Object(db_path: str, init_ddl: str | None = '')
saEngine: gws.lib.sa.Engine
execute(stmt: str, **params)

Execute a text DML statement and commit.

insert(table_name: str, rec: dict)

Insert a new record (dict) into a table.

select(stmt: str, **params) list[dict]

Execute a text select statement and commit.