Reputation: 1573
i want to display all the data in my table to a webpage using python when i click a button. here is my app.py code can anyone help me to finish this please..
def POST(self):
form = web.input(name="a", newname="s", number="d")
conn = MySQLdb.connect(host= "localhost", user="root", passwd="", db="testdb")
x = conn.cursor()
x.execute("SELECT * FROM details")
conn.commit()
items = cursor.fetchall()
return items()
conn.rollback()
conn.close()
return render.index()
i want to display it on index.html.and table has 3 colums
Upvotes: 1
Views: 4731
Reputation: 1395
def POST(self):
form = web.input(name="a", newname="s", number="d")
conn = MySQLdb.connect(host= "localhost", user="root", passwd="", db="testdb")
x = conn.cursor()
x.execute("SELECT * FROM details")
conn.commit()
items = cursor.fetchall()
for row in items:
print row[0], row[1]
conn.rollback()
conn.close()
return render.index(items)
Run this code and check output in terminal and let me know the data is comming or not
Upvotes: 1