1

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

3
  • post your index.html code Commented Sep 29, 2016 at 10:52
  • <h1>Data</h1> <br/> <br> <table border="1"> <tr> <th>Name></th> <th>address</th> <th>number</th> </tr> <tr> <td></td> <td></td> <td></td> </tr> Commented Sep 29, 2016 at 10:59
  • i left last <td> parts because i dont know how to call it to this form Commented Sep 29, 2016 at 11:02

1 Answer 1

1
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

Sign up to request clarification or add additional context in comments.

1 Comment

__template__() takes exactly 1 argument (0 given) i got this errror.can you just tell me how to call these row values to index.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.