A lot of the programming I do to support my own research involves writing code to manipulate Postgres databases. Naturally, I do all of this in PLT Scheme. Now that I’ve become reasonably proficient in working with a database from Scheme, I figured I should be able to quickly hack up a little tool for myself.
Something I’ve been meaning to do for a long time is find a way to permanently archive my emails, and have them be easily searchable. A real database is a solution to this problem—it’s a piece of technology that is designed to store lots of information, and has an interface (SQL) that lots of languages and tools can make use of. Databases are easily dumped and backed up, meaning my mail is not ‘locked in’ to a proprietary solution.
So, now I can write things like
select * from kent_messages where sender ~ '^D[a-z].*'
to find all the messages from people whose first name starts with the letter ‘D’, and I’m looking at ways of full-text indexing the contents of my mail for quick and easy search.
And, it’s easy: the script makes a (secure! whoo!) connection to my IMAP account, and then copies all the messages into Postgres running on my local machine. In truth, that database could be anywhere; there’s nothing that says the database has to be local; in this case, it happens to be.
I imported the 680+ messages from my INBOX today; I’m going to start thinking about how to import all the old messages I have from years past. No doubt, I’ll think of something.