我失去了 3 个小时,我无法弄清楚我做错了什么。请帮忙。我得出的结论是它没有像在更新语句中那样传递密钥,因为我没有收到任何错误,但我也没有更新数据库。
conn = sqlite3.connect('mov.db')
c = conn.cursor()
old_rows = c.execute('SELECT imdb FROM movies WHERE desc="" and imdb<>"" and year<"1997"')
result = c.fetchall()
for row in result:
key = row[0] [2:]
try:
# Get a Movie object with the data about the movie identified by
# the given movieID.
movie = i.get_movie(key)
except IMDbError, e:
print "Probably you're not connected to Internet. Complete error report:"
print e
continue
print movie['title']
if movie.has_key('plot outline'):
m=movie['plot outline']
print m
print key
c.execute('UPDATE movies SET desc=? WHERE imdb=?',(m,key))
print c.rowcount
# Commit the changes and close everything.
conn.commit()
c.close()
conn.close()