Convert ruby db prep to python