我在Python新手Python腳本上cursor.execute掛起()
我調試現有腳本是如下,
print "Table name: %s " %table_name_r
print "Between: %s " % between
cursor = db.cursor()
print "Total Rows: %s " % cursor.rowcount
cursor.execute("""select contactid,li_url_clean,li_company,complink from """+ table_name_r +""" where li_company is not null and id_auto between """+between)
print "Execution complete"
我發現了以下輸出,
Table name: li_records
Between: 4 and 6
Total Rows: -1
我這裏有2個問題,
1)(已解決)我的表li_records
有91行,爲什麼我得到的行數爲-1?
2.)爲什麼我的腳本掛在cursor.execute
?
問題1解決:許多人一樣,你指出我得到的理由「-1」,是因爲我還沒有執行的查詢尚未
任何幫助表示讚賞。 在此先感謝。
您需要在cursor.execute() –
@picmate後調用cursor.rowcount謝謝,這回答我的第一個問題,但即使在我這樣做後,我的腳本仍然掛起。 –
我相信db是一個連接對象,對嗎? –