Ulug'bek
Ulug'bek

Reputation: 2832

Python keeps giving an error when execute sql request

In this case, this project was writen on python 3.4, works with mysql(especially uses pymysql library). Getting this error while execute sql request: mysql error sql: unpack_from requires a buffer of at least 8 bytes. It tries to execute the sql query below:

sql = """
        SELECT n.name
        FROM %s n
        WHERE n.ID = %d """ % (globals.tbl_notification_type, notificationTypeID)

Anybody came accross simular problems?

Upvotes: 1

Views: 113

Answers (1)

Dylan Su
Dylan Su

Reputation: 6065

Try to replace %d with %s:

sql = """
    SELECT n.name
    FROM %s n
    WHERE n.ID = %s """ % (globals.tbl_notification_type, notificationTypeID)

Upvotes: 2

Related Questions