def selectRecord(request):
#cursor = conn.cursor()
cursor = conn.cursor(pymysql.cursors.DictCursor)
cursor.execute('select * from book ', [])
books = cursor.fetchall()
conn.close()
return HttpResponse(books)
这段代码用conn.cursor() 可以正常执行
用 cursor = conn.cursor(pymysql.cursors.DictCursor)
报错 cursor() takes 1 positional argument but 2 were given
这是为什么?
© 2021 Python学习网 苏ICP备2021003149号-1