Initial try at implementing text_counter

Warning: this code written by somebody has never used SQLite so it's
probably horrific. Somebody come along and tidy up after me please :-)

Specifically I'm sure there must be a less crappy way to do the "update count and get count back" in a single query...?

Time to go get some lunch! #ye2013 ;)