pymysql.err.InternalError: 1075

pymysql.err.InternalError: (1075, 'Incorrect table definition; there can be only one auto column and it must be defined as a key')

pymysql.err.InternalError: 1075
python中使用pymysql創建table是報錯是上面標題,sql語句如下:
sql = '''
create table music (
id int not null auto_increment,
song text,
singer text,
genre text,
issue text,
publisher text,
score text)'''
百度,問題是:自增字段必須是主鍵。解決辦法是設置id爲主鍵。
修改後sql爲:
sql = '''
create table music (
id int not null auto_increment,
song text,
singer text,
genre text,
issue text,
publisher text,
score text,
primary key(id)
)'''
感謝:https://www.cnblogs.com/guodongdidi/p/6290782.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章