Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Database configuration of Django in Python Framework

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Ready to start the python environment, use the django framework whose default database is sqlite3, and use mysql to store data instead

There was a problem executing migrate (see error at the end):

Unhandled exception in thread started by

Traceback (most recent call last):

File "C:\ Python36\ lib\ site-packages\ django\ db\ backends\ base\ base.py", line 213

, in ensure_connection

Self.connect ()

File "C:\ Python36\ lib\ site-packages\ django\ db\ backends\ base\ base.py", line 189

, in connect

Self.connection = self.get_new_connection (conn_params)

File "C:\ Python36\ lib\ site-packages\ django\ db\ backends\ mysql\ base.py", line 27

4, in get_new_connection

Conn = Database.connect (* * conn_params)

File "C:\ Python36\ lib\ site-packages\ MySQLdb\ _ init__.py", line 86, in Connect

Return Connection (* args, * * kwargs)

File "C:\ Python36\ lib\ site-packages\ MySQLdb\ connections.py", line 204, in _ _ in

It__

Super (Connection, self). _ _ init__ (* args, * kwargs2)

_ mysql_exceptions.OperationalError: (1045, "Access denied for user 'ODBC'@'local

Host' (using password: YES) ")

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

Traceback (most recent call last):

File "C:\ Python36\ lib\ site-packages\ django\ utils\ autoreload.py", line 227, in

Wrapper

Fn (* args, * * kwargs)

File "C:\ Python36\ lib\ site-packages\ django\ core\ management\ commands\ runserver.

Py ", line 125, in inner_run

Self.check (display_num_errors=True)

File "C:\ Python36\ lib\ site-packages\ django\ core\ management\ base.py", line 359

In check

Include_deployment_checks=include_deployment_checks

File "C:\ Python36\ lib\ site-packages\ django\ core\ management\ base.py", line 346

In _ run_checks

Return checks.run_checks (* * kwargs)

File "C:\ Python36\ lib\ site-packages\ django\ core\ checks\ registry.py", line 81

In run_checks

New_errors = check (app_configs=app_configs)

File "C:\ Python36\ lib\ site-packages\ django\ core\ checks\ model_checks.py", line

30, in check_all_models

Errors.extend (model.check (* * kwargs))

File "C:\ Python36\ lib\ site-packages\ django\ db\ models\ base.py", line 1282, in c

Heck

Errors.extend (cls._check_fields (* * kwargs))

File "C:\ Python36\ lib\ site-packages\ django\ db\ models\ base.py", line 1357, in _

Check_fields

Errors.extend (field.check (* * kwargs))

File "C:\ Python36\ lib\ site-packages\ django\ db\ models\ fields\ _ init__.py", line

909, in check

Errors = super (AutoField, self). Check (* kwargs)

File "C:\ Python36\ lib\ site-packages\ django\ db\ models\ fields\ _ init__.py", line

219, in check

Errors.extend (self._check_backend_specific_checks (* * kwargs))

File "C:\ Python36\ lib\ site-packages\ django\ db\ models\ fields\ _ init__.py", line

322, in _ check_backend_specific_checks

Return connections [db] .validation.check _ field (self, * * kwargs)

File "C:\ Python36\ lib\ site-packages\ django\ db\ backends\ mysql\ validation.py", l

Ine 49, in check_field

Field_type = field.db_type (self.connection)

File "C:\ Python36\ lib\ site-packages\ django\ db\ models\ fields\ _ init__.py", line

640, in db_type

Return connection.data_ types [self.get _ internal_type ()]% data

File "C:\ Python36\ lib\ site-packages\ django\ utils\ functional.py", line 35, in _

_ get__

Res = instance.__dict__ [self.name] = self.func (instance)

File "C:\ Python36\ lib\ site-packages\ django\ db\ backends\ mysql\ base.py", line 17

4, in data_types

If self.features.supports_microsecond_precision:

File "C:\ Python36\ lib\ site-packages\ django\ utils\ functional.py", line 35, in _

_ get__

Res = instance.__dict__ [self.name] = self.func (instance)

File "C:\ Python36\ lib\ site-packages\ django\ db\ backends\ mysql\ features.py", lin

E 53, in supports_microsecond_precision

Return self.connection.mysql_version > = (5,6,4) and Database.version_info

> = (1,2,5)

File "C:\ Python36\ lib\ site-packages\ django\ utils\ functional.py", line 35, in _

_ get__

Res = instance.__dict__ [self.name] = self.func (instance)

File "C:\ Python36\ lib\ site-packages\ django\ db\ backends\ mysql\ base.py", line 38

5, in mysql_version

With self.temporary_connection () as cursor:

File "C:\ Python36\ lib\ contextlib.py", line 82, in _ _ enter__

Return next (self.gen)

File "C:\ Python36\ lib\ site-packages\ django\ db\ backends\ base\ base.py", line 591

, in temporary_connection

Cursor = self.cursor ()

File "C:\ Python36\ lib\ site-packages\ django\ db\ backends\ base\ base.py", line 254

, in cursor

Return self._cursor ()

File "C:\ Python36\ lib\ site-packages\ django\ db\ backends\ base\ base.py", line 229

, in _ cursor

Self.ensure_connection ()

File "C:\ Python36\ lib\ site-packages\ django\ db\ backends\ base\ base.py", line 213

, in ensure_connection

Self.connect ()

File "C:\ Python36\ lib\ site-packages\ django\ db\ utils.py", line 94, in _ _ exit__

Six.reraise (dj_exc_type, dj_exc_value, traceback)

File "C:\ Python36\ lib\ site-packages\ django\ utils\ six.py", line 685, in reraise

Raise value.with_traceback (tb)

File "C:\ Python36\ lib\ site-packages\ django\ db\ backends\ base\ base.py", line 213

, in ensure_connection

Self.connect ()

File "C:\ Python36\ lib\ site-packages\ django\ db\ backends\ base\ base.py", line 189

, in connect

Self.connection = self.get_new_connection (conn_params)

File "C:\ Python36\ lib\ site-packages\ django\ db\ backends\ mysql\ base.py", line 27

4, in get_new_connection

Conn = Database.connect (* * conn_params)

File "C:\ Python36\ lib\ site-packages\ MySQLdb\ _ init__.py", line 86, in Connect

Return Connection (* args, * * kwargs)

File "C:\ Python36\ lib\ site-packages\ MySQLdb\ connections.py", line 204, in _ _ in

It__

Super (Connection, self). _ _ init__ (* args, * kwargs2)

Django.db.utils.OperationalError: (1045, "Access denied for user 'ODBC'@'localho

St' (using password: YES) ")

It's strange why the user I configured is admin_py. How can I display 'ODBC'@'localhost'?'?

Some people say that it is the account password error, which seems to be related to the account password error through the error report, but it is OK to log in MySQL manually!

After tossing about for a while, take a closer look at the official documentation configuration:

DATABASES = {'default': {' ENGINE': 'django.db.backends.postgresql',' NAME': 'mydatabase',' USER': 'mydatabaseuser',' PASSWORD': 'mypassword',' HOST': '127.0.0.1,' PORT': '5432,}}

My own configuration:

DATABASES = {'default': {' ENGINE': 'django.db.backends.mysql',' HOST': '127.0.0.1,' PORT': 3306, 'NAME':' platform_admin_py', 'USERNAME':' admin_py', 'PASSWORD':' admin',}}

Did you find out? The KEY of the user name is wrong! I admit that I read other people's configuration on the Internet. I'm lazy. That's the price.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report