i want to change database sqllite to mysql but show error

51 views
Skip to first unread message

Arun Sharma

unread,
Apr 12, 2020, 8:37:21 AM4/12/20
to Django users
python manage.py runserver



Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\db\backends\mysql\base.py", line 16, in
<module>
    import MySQLdb as Database
ModuleNotFoundError: No module named 'MySQLdb'

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

Traceback (most recent call last):
  File "C:\Users\Arunkumar\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 926, in _bootstrap_inner
    self.run()
  File "C:\Users\Arunkumar\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\utils\autoreload.py", line 53, in wrappe
r
    fn(*args, **kwargs)
  File "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\core\management\commands\runserver.py",
line 109, in inner_run
    autoreload.raise_last_exception()
  File "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\utils\autoreload.py", line 76, in raise_
last_exception
    raise _exception[1]
  File "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\core\management\__init__.py", line 357,
in execute
    autoreload.check_errors(django.setup)()
  File "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\utils\autoreload.py", line 53, in wrappe
r
    fn(*args, **kwargs)
  File "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\apps\registry.py", line 114, in populate

    app_config.import_models()
  File "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\apps\config.py", line 211, in import_mod
els
    self.models_module = import_module(models_module_name)
  File "C:\Users\Arunkumar\AppData\Local\Programs\Python\Python37-32\lib\importlib\__init__.py", line 127, in import_m
odule
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Users\Arunkumar\PycharmProjects\app2\project\models.py", line 4, in <module>
    class Project(models.Model):
  File "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\db\models\base.py", line 121, in __new__

    new_class.add_to_class('_meta', Options(meta, app_label))
  File "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\db\models\base.py", line 325, in add_to_
class
    value.contribute_to_class(cls, name)
  File "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\db\models\options.py", line 208, in cont
ribute_to_class
    self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
  File "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\db\__init__.py", line 28, in __getattr__

    return getattr(connections[DEFAULT_DB_ALIAS], item)
  File "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\db\utils.py", line 207, in __getitem__
    backend = load_backend(db['ENGINE'])
  File "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\db\utils.py", line 111, in load_backend
    return import_module('%s.base' % backend_name)
  File "C:\Users\Arunkumar\AppData\Local\Programs\Python\Python37-32\lib\importlib\__init__.py", line 127, in import_m
odule
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Users\Arunkumar\PycharmProjects\app2\venv\lib\site-packages\django\db\backends\mysql\base.py", line 21, in
<module>
    ) from err
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.
Did you install mysqlclient?










pip install mysqlclient
Collecting mysqlclient
03a/mysqlclient-1.4.6.tar.gz
Installing collected packages: mysqlclient
  Running setup.py install for mysqlclient ... error
    Complete output from command C:\Users\Arunkumar\PycharmProjects\app2\venv\Scripts\python.exe -u -c "import setupto
ols, tokenize;__file__='C:\\Users\\ARUNKU~1\\AppData\\Local\\Temp\\pip-install-5yg5lx4_\\mysqlclient\\setup.py';f=geta
ttr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec
'))" install --record C:\Users\ARUNKU~1\AppData\Local\Temp\pip-record-9s3l9mgb\install-record.txt --single-version-ext
ernally-managed --compile --install-headers C:\Users\Arunkumar\PycharmProjects\app2\venv\include\site\python3.7\mysqlc
lient:
    running install
    running build
    running build_py
    creating build
    creating build\lib.win32-3.7
    creating build\lib.win32-3.7\MySQLdb
    copying MySQLdb\__init__.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\_exceptions.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\compat.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\connections.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\converters.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\cursors.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\release.py -> build\lib.win32-3.7\MySQLdb
    copying MySQLdb\times.py -> build\lib.win32-3.7\MySQLdb
    creating build\lib.win32-3.7\MySQLdb\constants
    copying MySQLdb\constants\__init__.py -> build\lib.win32-3.7\MySQLdb\constants
    copying MySQLdb\constants\CLIENT.py -> build\lib.win32-3.7\MySQLdb\constants
    copying MySQLdb\constants\CR.py -> build\lib.win32-3.7\MySQLdb\constants
    copying MySQLdb\constants\ER.py -> build\lib.win32-3.7\MySQLdb\constants
    copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-3.7\MySQLdb\constants
    copying MySQLdb\constants\FLAG.py -> build\lib.win32-3.7\MySQLdb\constants
    running build_ext
    building 'MySQLdb._mysql' extension
    creating build\temp.win32-3.7
    creating build\temp.win32-3.7\Release
    creating build\temp.win32-3.7\Release\MySQLdb
    C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.25.28610\bin\HostX86\x86\cl.exe /c
 /nologo /Ox /W3 /GL /DNDEBUG /MD -Dversion_info=(1,4,6,'final',0) -D__version__=1.4.6 "-IC:\Program Files (x86)\MySQL
\MySQL Connector C 6.1\include\mariadb" -IC:\Users\Arunkumar\PycharmProjects\app2\venv\include -IC:\Users\Arunkumar\Ap
pData\Local\Programs\Python\Python37-32\include -IC:\Users\Arunkumar\AppData\Local\Programs\Python\Python37-32\include
 "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.25.28610\include" "-IC:\Program Fi
les (x86)\Windows Kits\10\include\10.0.17134.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\sh
ared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\um" "-IC:\Program Files (x86)\Windows Kits\10\inc
lude\10.0.17134.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\cppwinrt" /TcMySQLdb/_mysql.c
/Fobuild\temp.win32-3.7\Release\MySQLdb/_mysql.obj /Zl /D_CRT_SECURE_NO_WARNINGS
    _mysql.c
    MySQLdb/_mysql.c(29): fatal error C1083: Cannot open include file: 'mysql.h': No such file or directory
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.25.28610\\
bin\\HostX86\\x86\\cl.exe' failed with exit status 2

    ----------------------------------------
Command "C:\Users\Arunkumar\PycharmProjects\app2\venv\Scripts\python.exe -u -c "import setuptools, tokenize;__file__='
C:\\Users\\ARUNKU~1\\AppData\\Local\\Temp\\pip-install-5yg5lx4_\\mysqlclient\\setup.py';f=getattr(tokenize, 'open', op
en)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:
\Users\ARUNKU~1\AppData\Local\Temp\pip-record-9s3l9mgb\install-record.txt --single-version-externally-managed --compil
e --install-headers C:\Users\Arunkumar\PycharmProjects\app2\venv\include\site\python3.7\mysqlclient" failed with error
 code 1 in C:\Users\ARUNKU~1\AppData\Local\Temp\pip-install-5yg5lx4_\mysqlclient\











Andrew Fetting

unread,
Apr 12, 2020, 1:54:10 PM4/12/20
to django...@googlegroups.com
Have you tried
pip3 install mysqlclient

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c788f1bd-0873-469b-ac3f-7eba6089f7a1%40googlegroups.com.

Ernest Thuku

unread,
Apr 12, 2020, 10:52:02 PM4/12/20
to Django users

May we see some of your files..precisely settings.py...and have you properly configured your MySQL app...either workbench or xampp?

To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOn-ttimiyTTqz%3DCQmEDLsGpHKC1y_oYehf1nF_F-aorEEjzYw%40mail.gmail.com.

myproblemsolution38

unread,
Apr 13, 2020, 9:28:44 AM4/13/20
to Django users
Just go to the settings.py file and make the following changes in Database section:
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'your_DatabaseName',
        'USER':'your_username',
        'PASSWORD':'your_password',
        'HOST':'localhost',
        'PORT':'your_portnumber'
    }
}
Reply all
Reply to author
Forward
0 new messages