Got database writing working