代码如下:
import mysql.connector
conn = mysql.connector.connect(user='test',password='123456',database='test',use_unicode='Ture')
cursor = conn.cursor()
cursor.execute('drop table if exists test1')
cursor.execute('create table test1(id int not null auto_increment primary key,name varchar(20))')
如果直接在MySQL里操作是可以以insert into test1 select null,'juno'或insert into test1 (name) values ('juno')或insert into test1 (id,name) values (null,'juno')这三种形式插入的,但放在MySQLdb中好像都不行。
各位有什么解决方法呢?
import mysql.connector
conn = mysql.connector.connect(user='test',password='123456',database='test',use_unicode='Ture')
cursor = conn.cursor()
cursor.execute('drop table if exists test1')
cursor.execute('create table test1(id int not null auto_increment primary key,name varchar(20))')
如果直接在MySQL里操作是可以以insert into test1 select null,'juno'或insert into test1 (name) values ('juno')或insert into test1 (id,name) values (null,'juno')这三种形式插入的,但放在MySQLdb中好像都不行。
各位有什么解决方法呢?