Instantiated a new db object in each API call.

The object is not thread-safe, so calling a function on it from more
than one API call at once would break things pretty badly. This fixes that.