slowly working out sqlite glue stuff