Parameterized 'db' so that it's available without using a messy global namespace.