我正在尝试一个程序,其中我有'table=qwes'和'field1=first,field2=second'。我需要获得每一行一次,它必须通过条件“如果一行有hello,那么它的true else false”。在
我使用了limit并需要增加偏移量,然后它必须返回到下一行查找true或false。同样,它应该结束,直到所有行都完成。在import MySQLdb
db = MySQLdb.connect(host="localhost", # your host, usually localhost
user="root", # your username
passwd="mysql", # your password
db="sakila") # name of the data base
cursor = db.cursor()
qas = 0
while(qas < 100)
qas = qas + 1
posts = "select * from ques LIMIT 1 OFFSET %s " %(qas)
cursor.execute(posts)
db.commit()
keywords=[]
a='hello'
for i in cursor_posts.fetchall():
keywords.append(i[0])
if a in keywords:
print true
else:
print false
raw_input("please press enter to continue")
请帮助我修复我的程序;我希望while循环执行到行可用为止。由于我缺乏知识,我把它默认为100英镑。在