2014-03-30 63 views
0

我得到一个错误,当我尝试运行存储过程 进口MySQLdb的连接MySQL把蟒蛇

db = MySQLdb.connect(host="localhost", # your host, usually localhost 
        user="root", # your username 
         passwd="root", # your password 
         db="P_CAT_teetws") # name of the data base 

# you must create a Cursor object. It will let 
# you execute all the queries you need 
cur = db.cursor() 
name="shakiiraa" 
cur.execute("CALL sp_ORDER_BY_name %s",name) 

# print all the first cell of all the rows 
for row in cur.fetchall() : 
    print row[0] 

_mysql_exceptions.ProgrammingError:(1064,“您的SQL语法错误;检查手册,该手册对应于你的MySQL服务器版本,在1" 号线附近使用'shakiiraa“”正确的语法)

回答

0

试试这个:

cur.execute("CALL sp_ORDER_BY_name(%s)",name) 
+0

它的工作谢谢 – user3479237