Jump to content


Photo

Chapter 9, Page 324


  • Please log in to reply
1 reply to this topic

#1 Structer

Structer

    New Member

  • Members
  • Pip
  • 6 posts

Posted 23 March 2013 - 02:21 PM

I get an error when I try and run this script. Can you tell me what is wrong?

import sqlite3

connection = sqlite3.connect('coachdata.sqlite')
cursor = connection.cursor()

import glob
import athletemodel

data_files = glob.glob("../data/*.txt")
athletes = athletemodel.put_to_store(data_files)

for each_ath in athletes:
name = athletes[each_ath].name
dob = athletes[each_ath].dob
cursor.execute("INSERT INTO athletes (name, dob) VALUES (?, ?)", (name, dob))
connection.commit()

cursor.execute("SELECT id from athletes WHERE name=? AND dob=?",
(name, dob))

the_current_id = cursor.fetchone()[0]

for each_time in athletes[each_ath].clean_data:
cursor.execute("INSERT INTO timing_data (athlete_id, value) VALUES (?, ?)”,
(the_current_id, each_time))

connection.commit()

connection.close()

#2 Structer

Structer

    New Member

  • Members
  • Pip
  • 6 posts

Posted 24 March 2013 - 03:39 AM

Ok I figured it out. Just needed to copy the latest athlete list and athlete model to working directory.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users