Jump to content


Photo

Chapter:manage Your Data


  • Please log in to reply
No replies to this topic

#1 subinalex

subinalex

    New Member

  • Members
  • Pip
  • 8 posts

Posted 30 March 2014 - 11:10 PM

Hi ,

I changed the add_timing_data.py as mentioned in page 348 as below.

import cgi
import os
import time
import sys
import yate
import sqlite3

print(yate.start_response('text/plain'))
"""
addr=os.environ['REMOTE_ADDR']
host=os.environ['REMOTE_HOST']
method=os.environ['REQUEST_METHOD']
cur_time=time.asctime(time.localtime())
print(host+","+addr+","+cur_time+":"+method+":",end='',file=sys.stderr)
"""
form_data=cgi.FieldStorage()
"""
for each_form_item in form.keys():
print(each_form_item + '->' + form[each_form_item].value,end='',file=sys.stderr)
print(file=sys.stderr)

"""
the_id=form_data['Athlete'].value
the_time=form_data['Time'].value

connection = sqlite3.connect('coachdata.sqlite')
cursor = connection.cursor()
cursor.execute("INSERT INTO timing_data(athlete_id,value) VALUES(?,?)",(the_id,the_time))

connection.commit()
connection.close()


print('OK.')




But this is throwing a key error on 'Athlete',I suspect if this is due to unamended test_form.py which sends value to add_timing_data.py.

In test_form.py,the only key is 'TimeValue',shouldnt it be amended to read in form_data['Athlete'] and form_data['Time'] values?

Please advise.

Edited by subinalex, 30 March 2014 - 11:11 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users