[Tutor] MySQLdb: at a complete loss

Servando Garcia garcia.servando at gmail.com
Sat Feb 18 17:19:11 CET 2006


Hello List
    I am at a complete loss. Here is a recap, just to be clear, I have 
been unable insert into a database using MySQLdb. I can only view the 
database.
My current configuration:
    1. Windows XP
    2. Python 2.4.2
    3 MySQLdb current version
    4. mysql  5.0.18-nt
    5. DEV-c++ current version.

My last script was very sloppy here is my current version
#!/usr/bin/python
import MySQLdb,pdb

#pdb.set_trace()
try:
    
db=MySQLdb.connect(host='localhost',user='root',passwd='081300',db='tut')
    cursor=db.cursor()
    name = raw_input("Please enter a Name: ")
    color =raw_input("Please enter a Color: ")
    cursor.execute("""INSERT INTO horses(name,color) 
VALUES("%s","%s")"""%(name,color))
    cursor.close()
   
except MySQLdb.OperationalError,message:
    errorMessage ='Error %d:n %s'%(message[0],message[1])
    print errorMessage

this script runs without error and does not affect the database in any 
manner.  The database does exist. User/Password are valid. I have run 
the above script , unchanged, on both Macintosh and Ubuntu with success.



More information about the Tutor mailing list