View difference between Paste ID: xq0UNsUZ and LM2eQF3R
SHOW: | | - or go back to the newest paste.
1
#!c:/Python34/python.exe -u
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
13-
print(unicode("""<!DOCTYPE HTML>
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>\r\n\r\n
19
        <body>
20-
            <table border="1">""","utf-8"))
20+
            <table border="1">""")
21
22
for (id,name) in cursor:
23-
    print(unicode("""<tr><td>{},{}</td></tr>""".format(id,name),"utf-8"))
23+
    print("""<tr><td>{},{}</td></tr>""".format(id,name))
24
25-
print(unicode("""</table>
25+
print("""</table>
26
        </body>
27-
        </html>""","utf-8"))
27+
        </html>""")
28
29
30
31
cnx.commit()
32
33
cursor.close()   
34
cnx.close()