I am creating a table in using MYSQLdb in Python
tdesc = "CREATE TABLE " + self.table_name + " ("
tdesc = tdesc + "title VARCHAR(500), "
tdesc = tdesc + "DbLink VARCHAR(500), "
tdesc = tdesc + "abstract VARCHAR(3000), "
tdesc = tdesc + "WikiLink VARCHAR(5000),"
tdesc = tdesc + "PRIMARY KEY (DbLink)"
tdesc = tdesc + ")"
self.cursor = self.conn.cursor ()
File “C:\Python27\lib\site-packages\MySQLdb\cursors.py”, line 174, in execute
self.errorhandler(self, exc, value)
File “C:\Python27\lib\site-packages\MySQLdb\connections.py”, line 36, in defaulterrorhandler
raise errorclass, errorvalue
OperationalError: (1071, ‘Specified key was too long; max key length is 767 bytes’)
yes my key is a bit long string. Could some one guide me how shall I deal with this key issue?
Without telling us what that DBLink column is supposed to do it is kind of hard to solve this …
Your key is too long, there are no two ways about it. You can do two things, either you make the DBLink column smaller. Or, alternatively, you could create a new primary key, say an auto-incremented id, and add a unique constraint to your DBLink column.