Hi Thanks to Allan,Danny,Pujo I did my simple python script for MySQL , the scripts add the data , and search for the data and display I have problem in searching email id ,ie If search for the [EMAIL PROTECTED] , I will not get any result , Guidance and advice needed for the reason for this behavior I had added my script in this mail Thanks Joseph John
********************************************************* """ This program is for to learn how to enter data to MySQL using python How to search not using OOP Have problem in searching email-id Why I do not get correct results when searching email id "@" string search containg "@" gives empty results """ import MySQLdb def selecter(): choice = None while choice != "0": print \ """ Data Base Entry for the Testing Env 0 - Quit 1 - Enter the Data 2 - Display The data 3 - Search The Company """ choice = raw_input("Choice :........") print if choice == "0": print "Good Bye ..." elif choice == "1": dataentry() elif choice == "2": datashow() elif choice == "3": datasearch() def dataentry(): name = raw_input("Enter the name of the company ") email_id = raw_input("\n Enter the email ID : ") phone_no = raw_input("Enter the Phone No : ") fax_no = raw_input("\n Enter the fax no : ") db = MySQLdb.connect(host="localhost",user = "john", passwd = "asdlkj", db = 'learnpython') entry = db.cursor() #entry.execute("""INSERT INTO contact """,(name,email_id,phone_no,fax_no,)) entry.execute("""INSERT INTO contact(name,email_id,phone_no,fax_no) VALUES (%s,%s,%s,%s)""",(name,email_id,phone_no,fax_no,)) print name , email_id , fax_no, phone_no def datashow(): db = MySQLdb.connect(host="localhost",user = "john", passwd = "asdlkj", db = 'learnpython') entry = db.cursor() entry.execute("SELECT * from contact") p = entry.fetchall() print p def datasearch(): print "Do U want to search by Name , email id , phone or fax " choice = None while choice != "0": print \ """ U want to search the contacts by 0 - Quit 1 - Name 2 - email_id 3 - phone 4 - fax """ choice = raw_input("Choice :........") print if choice == "0": print "Good Bye ..." elif choice == "1": searchbyname() elif choice == "2": searchbyemail() elif choice == "3": searchbyphone() elif choice == "4": searchbyfax() def searchbyname(): s_name = raw_input("Enter the name to be searched ") db = MySQLdb.connect(host="localhost",user = "john", passwd = "asdlkj", db = 'learnpython') entry = db.cursor() entry.execute("""SELECT * FROM contact WHERE name = %s""", (s_name,)) p = entry.fetchall() print p def searchbyemail(): s_email = raw_input("Enter the Email to be searched ") db = MySQLdb.connect(host="localhost",user = "john", passwd = "asdlkj", db = 'learnpython') entry = db.cursor() entry.execute("""SELECT * FROM contact WHERE email_id = %s""", (s_email,)) p = entry.fetchall() print p def searchbyphone(): s_phone= raw_input("Enter the Phone no to be searched ") db = MySQLdb.connect(host="localhost",user = "john", passwd = "asdlkj", db = 'learnpython') entry = db.cursor() entry.execute("""SELECT * FROM contact WHERE phone_no = %s""", (s_phone,)) p = entry.fetchall() print p def searchbyfax(): s_fax = raw_input("Enter the FAX no to be searched ") db = MySQLdb.connect(host="localhost",user = "john", passwd = "asdlkj", db = 'learnpython') entry = db.cursor() entry.execute("""SELECT * FROM contact WHERE fax_no = %s""", (s_fax,)) p = entry.fetchall() print p selecter() ___________________________________________________________ Yahoo! Photos NEW, now offering a quality print service from just 8p a photo http://uk.photos.yahoo.com _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor