python script to read a record and write to database