Advertisement
Guest User

Untitled

a guest
Mar 7th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #!/usr/bin/python
  2. import mysql.connector
  3. from mysql.connector import (connection)
  4. from mysql.connector import errorcode
  5.  
  6. cnx = connection.MySQLConnection(user='root', password='nika1606',host='127.0.0.1',database='test2')
  7.  
  8. cursor = cnx.cursor()
  9.  
  10. show_persons= ("Select * from persons")
  11. cursor.execute(show_persons)
  12. for (id,name) in cursor:
  13. print("""<!DOCTYPE HTML>
  14. <html>
  15. <head>
  16. <meta http-equiv="content-type" content="text/html charset="utf-8">
  17. <title>MySQL Table from Python</title>
  18. </head>
  19. <body>
  20. <table border="1">
  21. <tr><td>"{},{}".format(id,name)</td></tr>
  22. </table>
  23. </body>
  24. </html>""")
  25.  
  26. cnx.commit()
  27.  
  28. cursor.close()
  29. cnx.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement