WORK IN PROGRESS
The core here is my first attempt at a solution of this, combining ideas from browser_history.py and karlicoss/HPI/sqlite.py
to create a library/CLI tool to (as safely as possible) copy databases which may be in use from other applications
sqlite_backup
This exposes the python stdlib sqlite.backup
function as a library, with a couple extra steps.
The main purpose for writing this is to copy sqlite databases that you may not own -- perhaps it belongs to an application (your browser) and is locked since that's currently open, or the OS keeps it open while the computer is active (e.g. Mac with iMessage)
Features
- Has the option (true by default) to first safely copy the database from disk to a temporary directory, which is:
- useful in case the source is in read-only mode (e.g. in some sort of docker container)
- safer if you're especially worried about corrupting or losing data
- Uses
Cpython
s Connection.backup, which directly uses the underlying Sqlite C code
In short, this prioritizes safety of the data over performance, temporarily copied data files to /tmp
or memory usage - because we often don't know what the application may be doing while we're copying underlying sqlite databases
This was extracted out of the karlicoss/HPI
sqlite
module
If other tools exist to do this, please let me know!
Installation
Requires python3.7+
To install with pip, run:
pip install sqlite_backup
Usage
TODO: Fill this out
Usage: ...
Tests
git clone 'https://github.com/seanbreckenridge/sqlite_backup'
cd ./sqlite_backup
pip install '.[testing]'
mypy ./sqlite_backup
pytest