#!"C:\Python33\python.exe"
import mysql.connector
import cgi
import cgitb
cgitb.enable()
print ("Content-type: text/html\n\n")
print ("
Hello Python
")
# Create instance of FieldStorage
form = cgi.FieldStorage()
# Get data from fields
first_name = form.getvalue('first_name')
last_name = form.getvalue('last_name')
# Open database connection
db=mysql.connector.connect(host='localhost',port='3306',database='prac_data', user='root',password='')
# prepare a cursor object using cursor() method
cursor = db.cursor()
# Prepare SQL query to INSERT a record into the database
#sqlstmt = "SELECT * FROM EMPLOYEE WHERE FIRST_NAME = %(first_name)s AND LAST_NAME = %(last_name)s"
#try:
# Execute the SQL command
#cursor.execute(sqlstmt, {'first_name': first_name, 'last_name': last_name})
cursor.execute("SELECT * FROM student WHERE name = %s AND address = %s;",[first_name, last_name])
# Fetch all the rows in a list of lists.
results = cursor.fetchall()
for row in results:
fname = row[0]
lname = row[1]
# age = row[2]
# sex = row[3]
# income = row[4]
# Now print fetched result
print ("fname=%s,lname=%s" % \
(fname, lname))
#except:
#print ("Error: unable to fecth data")
# disconnect from server
db.close()