Close cursor before closing connection
Improve --updatelocation speed

Change implementation of update_location function to not check and
update citydef_uid in one sql query.