I am newbie to python ,trying with simple programs given below is a program which i tried to get the data from table and displaying it. Installed Python3.4 and mysql.connector 2.0.4, runningin localhost as http://localhost:804/cgi-bin/ex7.py
It's connecting to database but not fetching the data from table
#!"C:\python34\python.exe"
import sys
import mysql.connector
print("Content-Type: text/html;charset=utf-8")
print()
conn = mysql.connector.connect(host='localhost',port='8051',
database='example',
user='root',
password='tiger')
cursor = conn.cursor()
if conn.is_connected():
print('Connected to MySQL database')
cursor.execute(""" SELECT * FROM album """)
for row in cursor:
print (row[1])
It's giving output as : Connected to MySQL database
not printing data from table Please suggest where went wrong