stfg

Crates.iostfg
lib.rsstfg
version0.1.0
created_at2025-08-07 12:56:44.211069+00
updated_at2025-08-07 12:56:44.211069+00
descriptiona tool that converts sqlite to/from git-friendly format
homepage
repositoryhttps://github.com/baehyunsol/stfg
max_upload_size
id1785238
size58,674
(baehyunsol)

documentation

https://docs.rs/stfg

README

A tool that converts sqlite to/from git-friendly format

This is a tool made by me and made for me, to solve a very specific problem: version-control sqlite.

I love git and sqlite. Both are very reliable and feature-rich. I use them a lot. One problem is that it's very difficult to version-control an sqlite DB with git. You can add the database file to the git repository, but git's not very good at dealing with binary files. You can't git diff binary files, you can't git blame them. Also, git works better with many small files than a single huge file.

So I made this tool. I'm satisfied with it, and I hope you like it too!

How to install

  1. Build from source
git clone https://github.com/baehyunsol/stfg
cd stfg
cargo build --release
  1. Build with cargo
cargo install stfg
  1. Use pre-built binaries

Coming soon!

How to use

  1. git commit your database
# This will create a directory `db/` and dump the data to the directory.
# If `db/` already exists, it removes files in the directory. So be careful!
stfg to-git your-database.db -o db/

# Then, run whatever git command you want.
git add db
git commit
  1. git checkout older version of your database
git checkout older-version-of-your-database

# Let's assume that `db/` is an output of `stfg to-git` command.
# It overwrites `your-database.db` if it already exists.
stfg from-git db/ -o your-database.db

# Now `your-database.db` contains an older version of your data.
  1. git diff between 2 versions of your database
# Let's assume that `db/` is an output of `stfg to-git` command.
# stfg creates a subdirectory per table under `db/`, so you can
# easily browse the contents of each table.
git diff HEAD~1:db/your_table_name HEAD:db/your_table_name

FAQ

  1. Why not just use .dump command of sqlite?

Yeah that works, and many of you might find that better than my solution. But I think my solution is more git-friendly because 1) it splits the database into small files instead of creating a single huge file and 2) it guarantees each field of the database is exactly one line in a file.

  1. Can I use this in production?

I don't think so. It's my personal project. There must be a lot of rough edges. Feedbacks and contributions are welcome!!

Commit count: 0

cargo fmt