'fun' with python and databases
In the chaos of moving house earlier this year, I decided to write a little web app to catalogue all the books and CDs I own.
Partly procrastination (packing is dull!), but mostly as an excuse to write something in Python - which we're using more of at work, and I'm nowhere near good at yet!
So I got a very basic thing mostly working using Flask, SQLAlchemy and Twitter Bootstrap. I remember being fairly smug about it, then leaving the code in a horrible disorganised mess because I actually did have better things to do (such as packing all the books into boxes to move them...)
Anyway, last week I finally got round to doing a bit more work on it. Or that was the plan, anyway..
First up, I had to have a small fight with my virtual environment, as the upgrade to 12.04 had knobbled it a bit. thanks for that, ubuntu.
Then... loads of my data was missing. Very confusing. I know I'd left the database in a fairly accurate state, and yet there it was, lacking several important columns and with only half the rows in anyway. WTF?
Some amount of swearing later, it occurred to me what the problem was.. every now and again I import a backup of my live blog database, but it turns out I've actually been importing all of the databases from my server, and hence overwriting the books database with an older backup of itself. d'oh!
This also explains why my mysql root password has been randomly changing itself. I've been tearing my hair out over this for months - blaming all sorts of things Ubuntu related, when actually it's been caused my my own idiocy. more d'oh!
So that's all sorted now, but took far too much time so actual progress with the development didn't really happen
I thought I'd tidy the code a bit, move things into separate files rather than all in one place. Which works, to a point - but flask likes all its routing/urls defined in one place, so now I've got code spread all over the place, which feels even more messy somehow.
The main cause of my frustration is, I think, that I am trying to jump too far up the learning curve in one go. Need to take smaller steps! (Friday evening code sessions also tend to involve a pint of cider, which may not help...)