0
我編寫了一些用於檢查現有行的表的代碼,然後如果該id不存在,代碼將插入新行。下面是代碼python在添加新行之前檢查現有行時出錯
x.execute("SELECT id FROM headlines WHERE id="+ pid)
numrows = int (x.rowcount)
if numrows<1:
sql = '''insert into headlinesUS (id,feed_url,item_title,item_date,fetch_date)
values ("%s","%s","%s","%s","%s");'''
x.execute(sql, (pid,url,title,date,fetch))
connection.commit()
print("\n- " + title)
但是當我運行它,我收到此錯誤:
numrows = int (x.rowcount)
^
IndentationError: unindent does not match any outer indentation level
檢查您的空間中沒有任何標籤混合。如果有疑問,請刪除空格並再次縮進。 –