r/SQL • • 10d ago

PostgreSQL PostgreSQL For personal budgeting and finance?

Im somewhat new to SQL and i want to apply it to my personal life so its easy to keep my skills and knowledge of it fresh since its what i want to do in the future.

I was thinking about setting up a local PostgreSQL database to use with VSCode on my personal computer to just monitor and record my everyday things like my banking/budgeting, random projects that i fall into a hole working on, etc.

I wanted to get some opinions on if this is a good idea, is it safe security wise, is there a better way to go about this, should i just scrap this idea, etc.

Please let me know and educate me!

Everytime i look it up its mainly about business related things like for creating apps etc. but i dont really plan on using it for anything other than my personal projects and plans.

(I chose postgresql because its just one of the more common ones ive seen in job postings etc. and i saw its pretty much free locally)

16 Upvotes

16 comments sorted by

4

u/Eleventhousand 10d ago

I have a Postgres at home that I use for various projects. I also have a SQL Server. It's safe. Just don't expose it to the public internet.

3

u/Discordbothost 10d ago

worth setting up early: COPY the bank csv into a staging table, then transform into your real tables. a unique constraint on (posted_date, amount, description) makes re-imports idempotent. and store amounts as numeric, not float.

3

u/Hour-Measurement-835 10d ago

Two coffees at the same price on the same day trip that (posted_date, amount, description) key. I'd use the bank's transaction ID instead, not sure every bank's CSV has one.

→ More replies (1)

2

u/gumnos 10d ago edited 10d ago

If your goal is a pet project, then sure, have at it.

If you're looking for something pre-formed, GNU Cash stores data in multiple formats, including PostgreSQL and might be a nice place to start.

Personally, I just use r/plaintextaccounting for my finances, storing my transactions in plain-text files and using hledger (I used to use ledger, and haven't really tried BeanCount) to report on my data.

Security-wise, it's as secure as you make it. If you are using a database, it's as secure as your disk/connection/credentials allow it to be (some file-systems make this easy like ZFS or devices like FreeBSD's GELI virtual-disks). If you're using flat-files with a ledger-like, you can even encrypt them with GPG and then pipe them to the [h]ledger binary with -f - to read from stdin like

$ gpg -qd finances.ledger.asc | hledger -f - balance

(that assumes you have an $EDITOR that lets you edit GPG files, like vi/vim/ed/emacs or maybe something else…I know those work)

1

u/Top-Pomelo659 10d ago

yeah, a small spending tracker sounds like a useful practice project: try separate categories and transactions tables, then monthly totals. i'd start with made-up transactions rather than real bank data, and keep it local. postgres defaults listen_addresses to localhost (local TCP connections only), but that setting alone isn't a security guarantee.

1

u/mirinai_ai 10d ago

It's a good way to keep SQL fresh, mostly because real data raises questions tutorial datasets don't. A few things that haven't come up yet:

Keep every CREATE TABLE and later change in .sql files in a folder (in git if you use it), so you can drop and rebuild the database from scratch whenever you redesign something. A first schema usually gets reworked a few times.

Back it up. A scheduled pg_dump to another drive, and actually restoring it into a fresh database once, is the step most home projects skip until a disk dies.

Plan for transfers between your own accounts, like moving money to savings or paying off a credit card. If those are stored as ordinary expenses, monthly spending gets counted twice. A transfer flag or a separate transfers table avoids that.

Once some data is in, the reports are where the practice pays off: monthly totals per category with GROUP BY and date_trunc, a running balance with SUM() OVER (ORDER BY the date column), and month-over-month change with LAG. Saving those as views gives you a small dashboard you can query straight from VS Code.

1

u/throwawayforwork_86 10d ago

Postgres is mostly fine so long as you don't open your port to the world as someone said should be secured enough.

Personally would go for DuckDB (or Sqlite) for these type of local projects unless what you want to learn is to specifically manage a PSQL server if it's to learn/keep SQL up to date you have more options since most of the language will be roughly the same across most flavors.

1

u/FuelSignificant1466 9d ago

your idea is not bad. as postgresql is free to run locally and you dont need to build any apps around it, i would say go for it. you will stay motivated while learning it

1

u/markinatlanta 9d ago

I think it's a good learning project because you’ll actually care whether the numbers are right. Import the same bank CSV twice and suddenly duplicate detection becomes much more interesting than a tutorial exercise.

Start with accounts, transactions and categories. Use made-up data while learning, then bring in real exports once you’re comfortable. Keep it local, leave bank login details out of it, and practise restoring a backup too.

A spreadsheet would be simpler for budgeting, but learning PostgreSQL is part of the point here

1

u/arwinda 9d ago

I get the idea to learn something new.

If you want to keep track of your finances, I'd suggest you look into existing tools. Over time you find a million things you did not have on your radar when you started the project. You can still contribute to the project of your choice, and learn SQL along the way. Just the learning curve is not very steep.

1

u/obviousoctopus 9d ago

It would be a great exercise. Go for it.

1

u/CedarAndOlive 6d ago

This has inspired me to do the same. 👍

0

u/Available_Safe1818 10d ago

I would scrap the idea. Whatever you want to accomplish, there are probably better ways.