用tkinter下拉框获取值查询数据库失败
def searchim(self):self.n1 = self.value.get()
self.n2 = self.numberChosen.get()
conn = pymssql.connect(host="192.168.1.3",user= "sa",password= "wyc1997827", database="stu", charset='utf8',autocommit = True )
cursor = conn.cursor()
sql = "SELECT * FROM rsm WHERE self.n2 LIKE '%self.n1'"
cursor.execute(sql)
results = cursor.fetchall()
for data in results:
print(data)
cursor.close()
conn.close()
我使用tkk模块的combobox控件设置了下拉框,然后又设置了一个普通输入框,上面代码里self.n1获得的是输入框的值,self.n2获得的是下拉框的值,然后使用select语句查询数据库中self.n2字段值为self.n1的数据,结果弹出如图错误,求大神解答!感谢! 请发完整代码!
页:
[1]