Welcome Guest.

1Answers

Trouble with python to see why creating multiple tables is unsuccessful. If only the first teacher is left, it can be created successfully.

Asked by: Joseph King 205 views IT January 9, 2019

cursor.execute("drop table if exists teacher")

cursor.execute ("""

CREATE TABLE teacher

(

id INT,

name VARCHAR(40),

course1 VARCHAR(40),

course2 VARCHAR(40)

)

""")

 

cursor.execute ("""

INSERT INTO teacher (id, name, course1, course2)

VALUES

(1, 'A', 'a', 'b'),

(2, 'B', 'c', 'd'),

(3, 'C', 'e', ​​'f')

""")

 

cursor.execute("drop table if exists class")

cursor.execute ("" "

CREATE TABLE class

(

id INT,

sign VARCHAR(40),

 

)

""")

 

cursor.execute ("""

INSERT INTO class (id, sian)

VALUES

(101, 1),

(102, 0),

(103, 1)

""")

 

cursor.execute("drop table if Exists a")

cursor.execute (""&q Uot;

CREATE TABLE a

(

id INT,

ask INT,

escape INT,

score INT

)

""")

 

cursor.execute ("""

INSERT INTO a (id, ask, escape, score)

VALUES

(1, 1, 0, 4) ,

(2, 0,0, 5),

(3, 1, 1, 2),

        (4, 0, 1, 3)

""")

 

cursor.execute("drop table if exists si")

cursor.execute ("""

CREATE TABLE si

(

id INT,

name VARCHAR(40),

tel INT,

photo VARCHAR(40)

)

""")

 

cursor.execute ("""

INSERT INTO si (id, name, tel, photo)

VALUES

(1, 'A', 111, 'b'),

(2, 'B', 222, 'd'),

(3, 'C', 333, 'f')

""")

 

db .commit()

cursor.close()

db.close()

This is an error:

ProgrammingError: (1064 , "You have an error in your SQL Syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 6")

1 Answers

  1. +1Votes  

    The syntax error of the SQL query statement is near the right parenthesis in the sixth line. The correct syntax needs to refer to the relevant manual of the MySQL server version.

    Larry Hall- January 9, 2019 |