General Posts

Stupid SQLite

I use SQLite to maintain the database for my blog. It is annoying sometimes when I could be using the very much more powerful MySQL, but I’m too cheap to opt for the extra money to add that ability to account. I feel like using MySQL for a blog database is like trying to swat a fly with a bazooka. If it came free with my site hosting, sure, I would use it, but it costs more money, and if I ran a store, or did something more interesting then blogging I would use it. But I don’t.

So my choices for storing my database for my blog would be berkelyDB, or SQLite. I choose SQLite because it was installed and looked simpler to use. It has now caused me two headaches. One when installing the plugin that allows for threaded comments. That is what makes the “reply to this” link work. I had to learn all this specific syntax and crap to add columns to my database. It took a long time, and it sucked. Now, because of the way SQLite handles files, I had a “locked” database for several days. I actually had stuff I wanted to write about. But the damned thing wouldn’t let me post anything at all. So after a few hours of pouring over the internet I start to find some things out. Maybe the file was locked using an operating system call? Maybe the program wrote a lock bit into the file header? Can I copy the file to a backup file, then delete the old one, clearing an operating system file? (that didn’t work) Maybe I just suck at Unix/Linux/BSD? In the end, I get one little clue how to fix this “locked” database. After many “SQL Error: Database is locked” messages, and much hair pulling (which reminds me, I need a hair cut) I find on a page describing all the commands you can throw at this highly versatile database software, a command description. This description says something to the effect of “This command commits any data created to the database, writes it to the table, writes the file, unlocks the database and deletes the journal file.” Sure enough there is a file called mtdb-journal. mtdb is the name of my database. I deleted the stupid journal file, and it !Wala! The system is working again.

So, now this is officially documented, and in a couple of days will be on google, so any idiot like me who can’t figure out how to unlock his database when SQLite takes a crap, can now have one more simple option to try.

Sometimes I feel like a huge nerd when an array of google searches can’t fix my problem. You know it’s bad when your the first person on the net to break non-beta software. Maybe I’ll start typing all of my real life (read not computer) problems into google and see which ones it brings up links for that can help me fix them. Man, that idea sounds like a bad sermon refrence….I hope my Dad doesn’t read this.