Track changes to SQLite tables using triggers
Project description
sqlite-history
Track changes to SQLite tables using triggers
Installation
Install this library using pip
:
pip install sqlite-history
Usage
This library can be used to configure triggers on a SQLite database such that any inserts, updates or deletes against a table will have their changes recorded in a separate table.
You can enable history tracking for a table using the enable_history()
function:
import sqlite_history
import sqlite3
conn = sqlite3.connect("data.db")
conn.execute("CREATE TABLE table1 (id INTEGER PRIMARY KEY, name TEXT)")
sqlite_history.configure_history(conn, "table1")
Or you can use the CLI interface, available via python -m sqlite_history
:
python -m sqlite_history data.db table1 [table2 table3 ...]
Use --all
to configure it for all tables:
python -m sqlite_history data.db --all
More details on how this works coming soon.
Development
To contribute to this library, first checkout the code. Then create a new virtual environment:
cd sqlite-history
python -m venv venv
source venv/bin/activate
Now install the dependencies and test dependencies:
pip install -e '.[test]'
To run the tests:
pytest
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for sqlite_history-0.1a0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d87da77501a2f69b46b594ad3f28d51fd2c7cdf58b8637edff9caad59afdb07 |
|
MD5 | dfe93123cb0c63b8a5c914a00c97747d |
|
BLAKE2b-256 | c0e8de9ea7b8d7fecef5963034ecab656d2190655266c49efd52e7a2fd8bdb37 |