Motivation
Found myself trying to compare the differences between two SQLite databases but since I was too lazy to figure out how to use SQLite Studio in order to do that (not sure if that is even possible by the way), I decided to extract all the rows from both databases using Python and then use Bash to find their differences.
The solution
- Usage of the
sqlite3
module to connect to the SQLite database, run a select SQL query to get all the rows, and then fetch all of them. - Usage of the
argparse
module to enable the user to specify the database, table and output file from the command line.
1 | import sqlite3 |