简体   繁体   中英

MySQL/Python - MySQLdb does not recognise table

I get the following error:

_mysql_exceptions.ProgrammingError: (1146, "Table 'test.imageupload' doesn't exist")

The database and table are there. I have dropped and created them again. I have also tried restarting the server. Nothing seems to work.

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

cur.execute("""INSERT INTO imageupload (uid, image_path,image_name) values (%s,%s,%s)""", (122, "kkk", "lll"))
db.commit()
db.close()

Have you tested if you are successfully connecting to the db ? if yes, try creating the table via cur.execute()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM