MySQLdb导入在Python 2.7.14中导致错误

时间:2019-02-06 14:41:37

标签: python mysql-python

我遇到以下错误:

  

回溯(最近一次通话最近):文件“ C:\ Python27 \ databasepy.py”,   第1行,在       在第19行中,导入MySQLdb文件“ C:\ Python27 \ lib \ site-packages \ MySQLdb__init __。py”          import _mysql ImportError:DLL加载失败:%1不是有效的Win32应用程序。

在执行以下代码时:

import MySQLdb
from MySQLdb import Error
try:
    db = MySQLdb.Connect(host="localhost",port=3306,user="root",passwd="Azmat@123",db="test")
    cursor=db.cursor()
    cursor.execute("SELECT VERSION()")
    data=cursor.fetchone()
    print "Database version :%s " %data
    db.close()
except Error as er:
    print er

0 个答案:

没有答案