Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!c:/Python34/python.exe -u
- import mysql.connector
- from mysql.connector import (connection)
- from mysql.connector import errorcode
- cnx = connection.MySQLConnection(user='root', password='nika1606',host='127.0.0.1',database='test2')
- cursor = cnx.cursor()
- show_persons= ("Select * from persons")
- cursor.execute(show_persons)
- print("""<!DOCTYPE HTML>
- <html>
- <head>
- <meta http-equiv="content-type" content="text/html charset="utf-8">
- <title>MySQL Table from Python</title>
- </head>\r\n\r\n
- <body>
- <table border="1">""")
- for (id,name) in cursor:
- print("""<tr><td>{},{}</td></tr>""".format(id,name))
- print("""</table>
- </body>
- </html>""")
- cnx.commit()
- cursor.close()
- cnx.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement