Bugfixes to database update in python