1
我使用web.py運行以下代碼以獲取mysql數據並將其打印在網頁上。出於某種原因,當我查詢網頁時,我只能看到「無」這個詞。任何想法是什麼問題? MySQL數據庫中有一些數據,憑據是有效的,代碼運行時沒有任何錯誤。Python MySQLdb查詢返回「None」
import web
import MySQLdb
import json
import collections
db=MySQLdb.connect(user="someuser",
passwd="somepass",db="somedatabase")
urls = (
'/', 'index',
'/test', 'test'
)
class index:
def GET(self):
c=db.cursor()
c.execute("""
SELECT email, password
FROM users
""")
rows = c.fetchall()
是的,這解決了問題。謝謝! – fedorp1