python hooks to db