close db connections
use os.rename isntead of shutil.move to replace existing files