2

I am very new to Django. I have created a sample project with Python v3.6 and Django V2.1. Initially, I have was using default sqlite3 database but now we have planned to change that into Mysql. For that, I have installed all the necessary plugin. On the other hand, I didn't create any table with sqlite3 except admin.

It is working fine if it was in default database when I change that into MySQL I am getting error which I can't resolve for a week :-(

    System check identified no issues (0 silenced).
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x0000000003A93C80>
Traceback (most recent call last):
  File "C:\Users\ccduce\AppData\Local\Continuum\miniconda3\lib\site-packages\django\db\backends\base\base.py", line 2
16, in ensure_connection

    self.connect()
  File "C:\Users\ccduce\AppData\Local\Continuum\miniconda3\lib\site-packages\django\db\backends\base\base.py", line 1
94, in connect
    self.connection = self.get_new_connection(conn_params)
  File "C:\Users\ccduce\AppData\Local\Continuum\miniconda3\lib\site-packages\django\db\backends\mysql\base.py", line
227, in get_new_connection
    return Database.connect(**conn_params)
  File "C:\Users\ccduce\AppData\Local\Continuum\miniconda3\lib\site-packages\MySQLdb\__init__.py", line 86, in Connec
t
    return Connection(*args, **kwargs)
  File "C:\Users\ccduce\AppData\Local\Continuum\miniconda3\lib\site-packages\MySQLdb\connections.py", line 204, in __
init__
    super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (2059, "Authentication plugin 'caching_sha2_password' cannot be loaded: The speci
fied module could not be found.\r\n")      
self.connect()
  File "C:\Users\ccduce\AppData\Local\Continuum\miniconda3\lib\site-packages\django\db\utils.py", line 89, in __exit_
_
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "C:\Users\ccduce\AppData\Local\Continuum\miniconda3\lib\site-packages\django\db\backends\base\base.py", line 2
16, in ensure_connection
    self.connect()
  File "C:\Users\ccduce\AppData\Local\Continuum\miniconda3\lib\site-packages\django\db\backends\base\base.py", line 1
94, in connect

    self.connection = self.get_new_connection(conn_params)
  File "C:\Users\ccduce\AppData\Local\Continuum\miniconda3\lib\site-packages\django\db\backends\mysql\base.py", line
227, in get_new_connection
    return Database.connect(**conn_params)
  File "C:\Users\ccduce\AppData\Local\Continuum\miniconda3\lib\site-packages\MySQLdb\__init__.py", line 86, in Connec
t
    return Connection(*args, **kwargs)
  File "C:\Users\ccduce\AppData\Local\Continuum\miniconda3\lib\site-packages\MySQLdb\connections.py", line 204, in __
init__
self.connect()
  File "C:\Users\ccduce\AppData\Local\Continuum\miniconda3\lib\site-packages\django\db\utils.py", line 89, in __exit_
_
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "C:\Users\ccduce\AppData\Local\Continuum\miniconda3\lib\site-packages\django\db\backends\base\base.py", line 2
16, in ensure_connection
    self.connect()
  File "C:\Users\ccduce\AppData\Local\Continuum\miniconda3\lib\site-packages\django\db\backends\base\base.py", line 1
94, in connect

    self.connection = self.get_new_connection(conn_params)
  File "C:\Users\ccduce\AppData\Local\Continuum\miniconda3\lib\site-packages\django\db\backends\mysql\base.py", line
227, in get_new_connection
    return Database.connect(**conn_params)
  File "C:\Users\ccduce\AppData\Local\Continuum\miniconda3\lib\site-packages\MySQLdb\__init__.py", line 86, in Connec
t
    return Connection(*args, **kwargs)
  File "C:\Users\ccduce\AppData\Local\Continuum\miniconda3\lib\site-packages\MySQLdb\connections.py", line 204, in __
init__
django.db.utils.OperationalError: (2059, "Authentication plugin 'caching_sha2_password' cannot be loaded: The specifi
ed module could not be found.\r\n")

If you suspect this is an IPython bug, please report it at:
    https://github.com/ipython/ipython/issues
or send an email to the mailing list at [email protected]

You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.


Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
    %config Application.verbose_crash=True

Error in atexit._run_exitfuncs:
    Traceback (most recent call last):
      File "C:\Users\ccduce\AppData\Local\Continuum\miniconda3\lib\site-packages\IPython\core\history.py", line 780, in w
    riteout_cache
        self._writeout_input_cache(conn)
      File "C:\Users\ccduce\AppData\Local\Continuum\miniconda3\lib\site-packages\IPython\core\history.py", line 764, in _
    writeout_input_cache
        (self.session_number,)+line)

    sqlite3.ProgrammingError: SQLite objects created in a thread can only be used in that same thread.The object was crea
    ted in thread id 2548 and this is thread id 11036

Setting.py

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'shield_dev',
        'USER': 'root',
        'PASSWORD': 'root',
        'HOST': 'localhost',   # Or an IP Address that your DB is hosted on
        'PORT': '3306',
    }
}

Please let me know what I have done wrong with My

8
  • From where are you trying to run the Django server? How is IPython involved? Commented Aug 18, 2018 at 9:41
  • @Cyrlop I am running my Django in Window 7 Commented Aug 18, 2018 at 9:54
  • Do you have db named shield_dev in your MYSQL? Commented Aug 18, 2018 at 10:34
  • @JerinPeterGeorge No, I don't have any. I have experience with Ruby on Rails so in that framework, it will automatically create DB for us. That's why I didn't create DB manually. Commented Aug 18, 2018 at 10:37
  • check your mysql db Commented Aug 18, 2018 at 10:48

1 Answer 1

1

I had the same problem and proceed this way:

  1. install a newer version of sqlite3 which is 3.2.0
  2. delete db.sqlite3 (I did not create a new one after that)
  3. run command : python manage.py migrate
  4. python manage.py runserver
  5. python manage.py createsuperuser
  6. log in then add new user or add something in a model table.

Good luck

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.