pymysql.err.InternalError: (1075, 'Incorrect table definition; there can be only one auto column and it must be defined as a key')
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