Home > database >  To manipulate error rogrammingError: when the mysql database (1064, "You have an error in your
To manipulate error rogrammingError: when the mysql database (1064, "You have an error in your

Time:11-23

The code is as follows:
Name and id # is given stocks, create table in the database
Def establish_table (sto_id sto_name) : # input two strings
Table_name=sto_id + sto_name
Cursor=the cursor ()
Cursor. The execute (" USE stock_lists ")
Cursor. The execute (DROP TABLE IF the EXISTS "% s", (table_name))
SQL="" "
The CREATE TABLE whatever
(
The date the date,
HolderNum VARCHAR (255),
ClosePrice VARCHAR (255)
"" "
Cursor. The execute (SQL)
Cursor. The execute (" RENAME TABLE whatever TO % s ", (table_name))
MIT ()
db.comCursor. The close ()
Return table_name
An error display:
Traceback (the most recent call last) :
The File "E:/paqu paqu12. Py", line 148, in & lt; module>
Table_name=establish_table (stock [0], stock [1])
The File "E:/paqu paqu12. Py, 57, line in establish_table
Cursor. The execute (DROP TABLE IF the EXISTS "% s", (table_name))
The File "E: \ xuniproject \ venv \ lib \ site - packages \ pymysql \ your cursors py", line 170, in the execute
Result=self. _query (query)
The File "E: \ xuniproject \ venv \ lib \ site - packages \ pymysql \ your cursors py", line 328, in _query
Conn. Query (q)
The File "E: \ xuniproject \ venv \ lib \ site - packages \ pymysql \ connections py", line 517, in the query
Self. _affected_rows=self. _read_query_result (unbuffered=unbuffered)
The File "E: \ xuniproject \ venv \ lib \ site - packages \ pymysql \ connections py", line 732, in _read_query_result
Result. The read ()
The File "E: \ xuniproject \ venv \ lib \ site - packages \ pymysql \ connections py", line 1075, in the read
First_packet=self. Connection. _read_packet ()
The File "E: \ xuniproject \ venv \ lib \ site - packages \ pymysql \ connections py", line 684, in _read_packet
Packet. Check_error ()
The File "E: \ xuniproject \ venv \ lib \ site - packages \ pymysql \ protocol py", line 220, in check_error
Err. Raise_mysql_exception (self. _data while forming)
The File "E: \ xuniproject \ venv \ lib \ site - packages \ pymysql \ err py", line 109, in raise_mysql_exception
Raise errorclass (errno, errval)
Pymysql. Err. 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 1 ")

The Process finished with exit code 1
Pray god help solve
  • Related