The python sqlite3 update statement does not work

存储架构 2017-11-19

I lost 3 hours and I cannot figure out what I'm doing wrong. Please help. I came to conclusion that it does not pass key as it should in update statement because I don't receive any error, but i dont get the db updated either.

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="" identified="" by="" given="" movieid.="" except="" imdberror,="" e:="" print="" "probably="" you're="" not="" connected="" to="" internet.="" complete="" error="" report:"="" e="" continue="" movie['title']="" if="" movie.has_key('plot="" outline'):="" m="movie['plot" outline']="" c.execute('update="" movies="" set="" desc="?" where="" imdb="?',(m,key))" c.rowcount="" commit="" changes="" and="" close="" everything.="" conn.commit()="" c.close()="" conn.close()
  

You are cutting two characters from the key here, that's why it no longer matches the key in your table:

key = row[0] [2:]

您可能感兴趣的

python学习笔记–缓解眼睛疲劳的小工具... 工作之余想着劳逸结合,然后就点开了‘大家来找茬’的休闲游戏,结果发现这玩意儿并不怎么休闲。 原本双眼在日常的‘BUG与调试’中就很疲劳了,休闲后结果更加疲劳了。 本次功能需求为自动判断两图差异,从而达到缓解眼睛疲劳功能,主要使用了pywin32,PIL,PyQt5,最终达到效果如下: ...
Python : 6 Different ways to create Dictionaries In this article we will discuss different ways to create dictionary objects in python. What is a dictionary ? dictionary is a an associative conta...
Determine input encoding Ruby 1.9: Regular expressions with unknown input encoding Is there an accepted way to deal with regular expressions in Ruby 1.9 ...
How Netflix handles failovers, Anaconda, Linux com... With more than 12,000 page views, Amjith Ramanujam's article on how Netflix does failovers in 7 minutes flat was our runaway hit last week. Do you ha...
python web py入门(2)-URL处理 本文介绍URL映射,在介绍映射之前,我们先了解下什么是URL? URL(Uniform/Universal Resource Locator的缩写,统一资源定位符)是对可以从互联网上得到的资源的位置和访问方法的一种简洁的表示,是互联网上标准资源的地址。互联网上的每个文件都有一个唯一的URL,它包含的...