I use is mysql8 + phthon3.7 + pycharm2017.1
I'm mysql> Condition, choose wangjunlu database, create a table_name_5 data table, prompt and query successfully created
The following figure
But I use pycharm 2017.1, run the following content, a syntax error, a great god, please give directions:
# python + pymysql create database
The import pymysql
# open database connection
Conn=pymysql. Connect (host='localhost',
User="root",
Password="123456",
='wangjunlu' database,
Charset='utf8,
Cursorclass=pymysql. Your cursors. DictCursor)
# cursor method is used to create a cursor object cursor
Cursor=conn. Cursor ()
# using the execute () method to execute SQL, if the table is the delete
# cursor. The execute (DROP TABLE IF the EXISTS "ceshi")
# use prepared statements to create table
SQL=""
The CREATE TABLE table_name_5 (
Id INT PRIMARY KEY NOT NULL AUTO_INCREMENT PRIMARY KEY,
Column_2_name VARCHAR (10) NOT NULL
);
And in pycharm 2017.1 on the right side of the create new table in the database can also create success (pictured), if I write the code above there problems:
CodePudding user response:
How two primary key id columnCodePudding user response:
1. Id int no length2. There are two primary key id column
CodePudding user response:
The two primary key