0

I have got the following error:

Traceback (most recent call last): File "C:\Python27\databasepy.py", line 1, in import MySQLdb File "C:\Python27\lib\site-packages\MySQLdb__init__.py", line 19, in import _mysql ImportError: DLL load failed: %1 is not a valid Win32 application.

While executing the following code:

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
num3ri
  • 664
  • 11
  • 15
  • Possible duplicate of [Can't import MySQLdb module in Python](https://stackoverflow.com/questions/14262379/cant-import-mysqldb-module-in-python) – adambro Feb 06 '19 at 14:53
  • I'll suggest you use `pymysql` to replace `MySQLdb`. The prior one is a pure-Python implementation. – Philip Tzou Feb 06 '19 at 19:58

0 Answers0