Home > front end >  How to solve the Python3.6 Django2.2 a series of problems when using the MySQL database
How to solve the Python3.6 Django2.2 a series of problems when using the MySQL database

Time:10-04

 
Settings. The DATABASES of py attribute
The DATABASES={
"Default" : {
# 'ENGINE' : 'the django. Db. Backends. Sqlite3',
# 'NAME' : OS. Path. Join (BASE_DIR, 'db. Sqlite3'),

'ENGINE' : 'the django. Db. Backends. Mysql,
'HOST' : '127.0.0.1,
'PORT', '3306',
'NAME' : 'polls,
'USER' : 'root',
'PASSWORD' : 'root',
'OPTIONS' : {
'init_command' : 'the SET="STRICT_TRANS_TABLES"' sql_mode,
}
}
}

 
Just set py code
The import pymysql
Pymysql. Install_as_MySQLdb ()

Execute python manage. Py makemigrations
Show No Changes detected
Execute python manage. Py migrate
Error:
 
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
Traceback (the most recent call last) :
The File "G: \ Anaconda3 \ lib \ site - packages \ django 2.2 dev20180727211500 - py3.6. Egg \ django \ db \ backends \ utils py", line 83, in _execute
Return the self. The cursor. The execute (SQL)
The File "G: \ Anaconda3 \ lib \ site - packages \ django 2.2 dev20180727211500 - py3.6. Egg \ django \ db \ backends \ mysql \ base py", line 71, in the execute
Return the self. The cursor. The execute (query, args)
The File "G: \ Anaconda3 \ lib \ site - packages \ pymysql \ your cursors py", line 170, in the execute
Result=self. _query (query)
The File "G: \ Anaconda3 \ lib \ site - packages \ pymysql \ your cursors py", line 328, in _query
Conn. Query (q)
The File "G: \ Anaconda3 \ lib \ site - packages \ pymysql \ connections py", line 516, in the query
Self. _affected_rows=self. _read_query_result (unbuffered=unbuffered)
The File "G: \ Anaconda3 \ lib \ site - packages \ pymysql \ connections py", line 727, in _read_query_result
Result. The read ()
The File "G: \ Anaconda3 \ lib \ site - packages \ pymysql \ connections py", line 1066, in the read
First_packet=self. Connection. _read_packet ()
The File "G: \ Anaconda3 \ lib \ site - packages \ pymysql \ connections py", line 683, in _read_packet
Packet. Check_error ()
The File "G: \ Anaconda3 \ lib \ site - packages \ pymysql \ protocol py", line 220, in check_error
Err. Raise_mysql_exception (self. _data while forming)
The File "G: \ Anaconda3 \ 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 '(6) NOT NULL) at line 1 ")

The above exception was The direct cause of The following exception:

Traceback (the most recent call last) :
The File "G: \ Anaconda3 \ lib \ site - packages \ django 2.2 dev20180727211500 - py3.6. Egg \ django \ db \ migrations \ recorder py", line 55, in ensure_schema
Editor. Create_model (self. Migration)
The File "G: \ Anaconda3 \ lib \ site - packages \ django 2.2 dev20180727211500 - py3.6. Egg \ django \ db \ backends \ base \ schema py", line 314, in create_model
The self. The execute (SQL, params or None)
The File "G: \ Anaconda3 \ lib \ site - packages \ django 2.2 dev20180727211500 - py3.6. Egg \ django \ db \ backends \ base \ schema py", line 134, in the execute
Cursor. The execute (SQL, params)
The File "G: \ Anaconda3 \ lib \ site - packages \ django 2.2 dev20180727211500 - py3.6. Egg \ django \ db \ backends \ utils py", line 100, in the execute
Return super (). The execute (SQL, params)
The File "G: \ Anaconda3 \ lib \ site - packages \ django 2.2 dev20180727211500 - py3.6. Egg \ django \ db \ backends \ utils py", line 68, in the execute
Return the self. _execute_with_wrappers (SQL, params, many=False, executor=self. _execute)
The File "G: \ Anaconda3 \ lib \ site - packages \ django 2.2 dev20180727211500 - py3.6. Egg \ django \ db \ backends \ utils py", line 77, in _execute_with_wrappers
Return executor (SQL, params,, context)
The File "G: \ Anaconda3 \ lib \ site - packages \ django 2.2 dev20180727211500 - py3.6. Egg \ django \ db \ backends \ utils py", line 85, in _execute
Return the self. The cursor. The execute (SQL, params)
The File "G: \ Anaconda3 \ lib \ site - packages \ django 2.2 dev20180727211500 - py3.6. Egg \ django \ db \ utils py", line 89, in __exit__
Raise dj_exc_value. With_traceback (traceback) from exc_value
The File "G: \ Anaconda3 \ lib \ site - packages \ django 2.2 dev20180727211500 - py3.6. Egg \ django \ db \ backends \ utils py", line 83, in _execute
Return the self. The cursor. The execute (SQL)
The File "G: \ Anaconda3 \ lib \ site - packages \ django 2.2 dev20180727211500 - py3.6. Egg \ django \ db \ backends \ mysql \ base py", line 71, in the execute
Return the self. The cursor. The execute (query, args)
The File "G: \ Anaconda3 \ lib \ site - packages \ pymysql \ your cursors py", line 170, in the execute
Result=self. _query (query)
The File "G: \ Anaconda3 \ lib \ site - packages \ pymysql \ your cursors py", line 328, in _query
Conn. Query (q)
The File "G: \ Anaconda3 \ lib \ site - packages \ pymysql \ connections py", line 516, in the query
Self. _affected_rows=self. _read_query_result (unbuffered=unbuffered)
The File "G: \ Anaconda3 \ lib \ site - packages \ pymysql \ connections py", line 727, in _read_query_result
Result. The read ()
The File "G: \ Anaconda3 \ lib \ site - packages \ pymysql \ connections py", line 1066, in the read
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related