2
查詢
我試圖建立一個簡單的地址簿GUI,有一個wx.listbox
,它包含本書中所有的名字,第一個和最後一個。點擊後,它會從數據庫文件中返回附加到名稱的信息。現在我的工作只是姓氏,我想匹配名字和姓氏。我並不真的熟悉SQLite 3的命令和語法。python sqlite3與AND
功能如下,現在這個工作得很好,但我想查詢更改爲類似:
select * from AddressBook where Last like names[0] and First like names[1]
任何幫助將是巨大的!
def onListBox(self, event):
name = event.GetEventObject().GetStringSelection()
names = name.split(',')###names[0]=Last name, names[1] = first name
cursor = db.cursor()
cursor.execute("select * from AddressBook where Last like ?",('%'+names[0]+'%',))
result = cursor.fetchall()
return result
你嘗試查詢? – glibdud
您是否嘗試將第二個參數添加到查詢中? –
是的,它回來了一個語法錯誤 – mickNeill