SQLite Export for YNAB - Export YNAB Budget Data to SQLite
Project description
sqlite-export-for-ynab
SQLite Export for YNAB - Export YNAB Budget Data to SQLite
What this Does
Export your YNAB budget to a local SQLite DB
Installation
$ pip install sqlite-export-for-ynab
Usage
Run it from the terminal to download your budget:
$ sqlite-export-for-ynab
Running it again will pull only the data that changed since the last pull. If you want to wipe the DB and pull all data again use the --full-refresh
flag.
The DB is stored according to the XDG Base Directory Specification.
By default the DB is saved in "${XDG_DATA_HOME}"/sqlite-export-for-ynab/db.sqlite
.
If you don't set XDG_DATA_HOME
then by default the DB will be saved in ~/.local/share/sqlite-export-for-ynab/db.sqlite
.
Use the --db
argument to specify a different DB path.
SQL
The schema is defined in create-tables.sql. It is very similar to YNAB's OpenAPI Spec however some objects are pulled out into their own tables (ex: subtransactions, loan account periodic values) and foreign keys are added as needed (ex: budget ID, transaction ID).
You can query the DB with typical SQLite tools. For example, to get the top 5 payees by spending per budget, you could do:
WITH
ranked_payees AS (
SELECT
b.name AS budget_name,
p.name AS payee,
SUM(t.amount) / -1000.0 AS net_spent,
ROW_NUMBER() OVER (
PARTITION BY
b.id
ORDER BY
SUM(t.amount) ASC
) AS rnk
FROM
transactions t
JOIN payees p ON t.payee_id = p.id
JOIN budgets b ON t.budget_id = b.id
WHERE
p.name != 'Starting Balance'
AND p.transfer_account_id IS NULL
GROUP BY
b.id,
p.id
)
SELECT
budget_name,
payee,
net_spent
FROM
ranked_payees
WHERE
rnk <= 5
ORDER BY
budget_name,
net_spent DESC
;
Project details
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
File details
Details for the file sqlite_export_for_ynab-0.0.3.tar.gz
.
File metadata
- Download URL: sqlite_export_for_ynab-0.0.3.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 53dd7279593124a03b20dfc8d83b7ecc5ad5698c0187894fce2a4adc889a2396 |
|
MD5 | 656eb50d7189a2dcfa89c8a96fe54dc9 |
|
BLAKE2b-256 | ab0f5046a9bc912ca98cce26e2b68539bd13b586412ed2d8d86cfb34d13658d5 |
File details
Details for the file sqlite_export_for_ynab-0.0.3-py2.py3-none-any.whl
.
File metadata
- Download URL: sqlite_export_for_ynab-0.0.3-py2.py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 21cc8dffbb0fbae5974e879263dd4a648471d944700f6631678fc3ea4118d560 |
|
MD5 | 586bab1a19e7c0aecba21c7a0e3f9d67 |
|
BLAKE2b-256 | 8e44e6fe8c912e765eacbb1fce4f5903b7b7604fca588f44def7aadf84ed53bc |