Django Cannot Connect to Remote MySQL Server - python

I am running a Django and attempting to connect to a MySQL server at my university.
First of all:
In order to connect the database, I normally SSH into a remote server (with authentication) of theirs, and then run MySQL and enter my MySQL authentications.
This works without an issue, in Terminal as well as DataGrip.
Now, using PyCharm, I have installed mysqlclient in the intepreter and changed my
settings.py:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': '[DB_NAME]',
'USER': '[DB_USERNAME]',
'PASSWORD': '[DB_PASSWORD]',
'HOST': '[REMOTE SERVER ADDRESS HOSTING MYSQL]',
'PORT': '3306',
}
}
Also using PyCharm, I have even opened up a data source in the Data Sources Tool Window and connected through SSH tunnel and MySQL authentication to the database. This is successful, and it is possible to make queries.
However, I try to run:
manage.py check
and I receive:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site- packages/django/db/backends/base/base.py", line 213, in ensure_connection
self.connect()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/db/backends/base/base.py", line 189, in connect
self.connection = self.get_new_connection(conn_params)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 274, in get_new_connection
conn = Database.connect(**conn_params)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/MySQLdb/__init__.py", line 86, in Connect
return Connection(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/MySQLdb/connections.py", line 204, in __init__
super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (2003, "Can't connect to MySQL server on '[REMOTE SERVER ADDRESS HOSTING MYSQL]' (60)")
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/helpers/pycharm/django_manage.py", line 43, in <module>
run_module(manage_file, None, '__main__', True)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 205, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/Users/skillapop/Desktop/streamcity_project/manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
utility.execute()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/__init__.py", line 355, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/commands/check.py", line 68, in handle
fail_level=getattr(checks, options['fail_level']),
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/base.py", line 359, in check
include_deployment_checks=include_deployment_checks,
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/base.py", line 346, in _run_checks
return checks.run_checks(**kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/checks/registry.py", line 81, in run_checks
new_errors = check(app_configs=app_configs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/checks/model_checks.py", line 30, in check_all_models
errors.extend(model.check(**kwargs))
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/db/models/base.py", line 1283, in check
errors.extend(cls._check_fields(**kwargs))
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/db/models/base.py", line 1358, in _check_fields
errors.extend(field.check(**kwargs))
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/db/models/fields/__init__.py", line 913, in check
errors = super(AutoField, self).check(**kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/db/models/fields/__init__.py", line 219, in check
errors.extend(self._check_backend_specific_checks(**kwargs))
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/db/models/fields/__init__.py", line 322, in _check_backend_specific_checks
return connections[db].validation.check_field(self, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/db/backends/mysql/validation.py", line 49, in check_field
field_type = field.db_type(self.connection)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/db/models/fields/__init__.py", line 644, in db_type
return connection.data_types[self.get_internal_type()] % data
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 174, in data_types
if self.features.supports_microsecond_precision:
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/db/backends/mysql/features.py", line 53, in supports_microsecond_precision
return self.connection.mysql_version >= (5, 6, 4) and Database.version_info >= (1, 2, 5)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 385, in mysql_version
with self.temporary_connection() as cursor:
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/contextlib.py", line 81, in __enter__
return next(self.gen)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/db/backends/base/base.py", line 591, in temporary_connection
cursor = self.cursor()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/db/backends/base/base.py", line 254, in cursor
return self._cursor()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/db/backends/base/base.py", line 229, in _cursor
self.ensure_connection()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/db/backends/base/base.py", line 213, in ensure_connection
self.connect()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/db/backends/base/base.py", line 213, in ensure_connection
self.connect()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/db/backends/base/base.py", line 189, in connect
self.connection = self.get_new_connection(conn_params)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 274, in get_new_connection
conn = Database.connect(**conn_params)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/MySQLdb/__init__.py", line 86, in Connect
return Connection(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/MySQLdb/connections.py", line 204, in __init__
super(Connection, self).__init__(*args, **kwargs2)
django.db.utils.OperationalError: (2003, "Can't connect to MySQL server on '[REMOTE SERVER ADDRESS HOSTING MYSQL]' (60)")
It is also important to note that I HAVE connected a Django project to this exact same server and database before in a test run. Now, that test project and the new project does NOT connect.
Any help would be appreciated!

Related

Create a Django Database

This code works on other people's local computer - we aren't running it in production yet. But mine isn't working. A coworker indicated that I need to create a database. Prior to using mysql, I was using sqlite, which didn't require this.
When I run python manage.py runserver this is what I get:
XX-MacBook-Pro:xx xx$ python manage.py runserver
Performing system checks...
Unhandled exception in thread started by <function wrapper at 0x104ebb668>
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/Library/Python/2.7/site-packages/django/core/management/commands/runserver.py", line 116, in inner_run
self.check(display_num_errors=True)
File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 426, in check
include_deployment_checks=include_deployment_checks,
File "/Library/Python/2.7/site-packages/django/core/checks/registry.py", line 75, in run_checks
new_errors = check(app_configs=app_configs)
File "/Library/Python/2.7/site-packages/django/core/checks/model_checks.py", line 28, in check_all_models
errors.extend(model.check(**kwargs))
File "/Library/Python/2.7/site-packages/django/db/models/base.py", line 1170, in check
errors.extend(cls._check_fields(**kwargs))
File "/Library/Python/2.7/site-packages/django/db/models/base.py", line 1247, in _check_fields
errors.extend(field.check(**kwargs))
File "/Library/Python/2.7/site-packages/django/db/models/fields/__init__.py", line 925, in check
errors = super(AutoField, self).check(**kwargs)
File "/Library/Python/2.7/site-packages/django/db/models/fields/__init__.py", line 208, in check
errors.extend(self._check_backend_specific_checks(**kwargs))
File "/Library/Python/2.7/site-packages/django/db/models/fields/__init__.py", line 317, in _check_backend_specific_checks
return connections[db].validation.check_field(self, **kwargs)
File "/Library/Python/2.7/site-packages/django/db/backends/mysql/validation.py", line 18, in check_field
field_type = field.db_type(connection)
File "/Library/Python/2.7/site-packages/django/db/models/fields/__init__.py", line 625, in db_type
return connection.data_types[self.get_internal_type()] % data
File "/Library/Python/2.7/site-packages/django/db/__init__.py", line 36, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/Library/Python/2.7/site-packages/django/utils/functional.py", line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Library/Python/2.7/site-packages/django/db/backends/mysql/base.py", line 184, in data_types
if self.features.supports_microsecond_precision:
File "/Library/Python/2.7/site-packages/django/utils/functional.py", line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Library/Python/2.7/site-packages/django/db/backends/mysql/features.py", line 53, in supports_microsecond_precision
return self.connection.mysql_version >= (5, 6, 4) and Database.version_info >= (1, 2, 5)
File "/Library/Python/2.7/site-packages/django/utils/functional.py", line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Library/Python/2.7/site-packages/django/db/backends/mysql/base.py", line 359, in mysql_version
with self.temporary_connection():
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/contextlib.py", line 17, in __enter__
return self.gen.next()
File "/Library/Python/2.7/site-packages/django/db/backends/base/base.py", line 564, in temporary_connection
cursor = self.cursor()
File "/Library/Python/2.7/site-packages/django/db/backends/base/base.py", line 233, in cursor
cursor = self.make_cursor(self._cursor())
File "/Library/Python/2.7/site-packages/django/db/backends/base/base.py", line 204, in _cursor
self.ensure_connection()
File "/Library/Python/2.7/site-packages/django/db/backends/base/base.py", line 199, in ensure_connection
self.connect()
File "/Library/Python/2.7/site-packages/django/db/utils.py", line 95, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/Library/Python/2.7/site-packages/django/db/backends/base/base.py", line 199, in ensure_connection
self.connect()
File "/Library/Python/2.7/site-packages/django/db/backends/base/base.py", line 171, in connect
self.connection = self.get_new_connection(conn_params)
File "/Library/Python/2.7/site-packages/django/db/backends/mysql/base.py", line 264, in get_new_connection
conn = Database.connect(**conn_params)
File "/Library/Python/2.7/site-packages/MySQLdb/__init__.py", line 81, in Connect
return Connection(*args, **kwargs)
File "/Library/Python/2.7/site-packages/MySQLdb/connections.py", line 193, in __init__
super(Connection, self).__init__(*args, **kwargs2)
django.db.utils.OperationalError: (1049, "Unknown database 'testdb'")
My settings file has this:
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
...
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'testdb',
'USER': ‘xx’,
'PASSWORD': ‘xx’,
'HOST': 'localhost'
}
}
I've tested the user, password and know that they work. My MySQL is fully functional.
If I remove the DATABASES 'NAME' I get:
django.db.utils.OperationalError: (1046, 'No database selected')
Presumably you have tested the username and password by going into the mysql shell. So you can just do the same thing again, and from there do CREATE DATABASE testdb.

Django server not starting correctly seems to be a mysql issue.

I'm trying to start a django server and I'm getting an error I don't understand.
This is the error at the bottom of the terminal output:
django.db.utils.OperationalError: (2026, 'SSL connection error: error:00000001:lib(0):func(0):reason(1)')
This: Error Loading MySQLdb Module and "pip install MySQLdb"
Is a question I asked earlier that gives some background.
I'm really new to Django and python and I saw this: mysql ERROR 2026 (HY000): SSL connection error: error:00000001:lib(0):func(0):reason(1)
But I wasn't sure how to implement what it suggests.
Here is the full error:
Performing system checks...
Unhandled exception in thread started by <function wrapper at 0x101c358c0>
Traceback (most recent call last):
File "/Users/Bren/Desktop/fss/venv/lib/python2.7/site-packages/django/utils/autoreload.py", line 229, in wrapper
fn(*args, **kwargs)
File "/Users/Bren/Desktop/fss/venv/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 114, in inner_run
self.validate(display_num_errors=True)
File "/Users/Bren/Desktop/fss/venv/lib/python2.7/site-packages/django/core/management/base.py", line 469, in validate
return self.check(app_configs=app_configs, display_num_errors=display_num_errors)
File "/Users/Bren/Desktop/fss/venv/lib/python2.7/site-packages/django/core/management/base.py", line 482, in check
include_deployment_checks=include_deployment_checks,
File "/Users/Bren/Desktop/fss/venv/lib/python2.7/site-packages/django/core/checks/registry.py", line 72, in run_checks
new_errors = check(app_configs=app_configs)
File "/Users/Bren/Desktop/fss/venv/lib/python2.7/site-packages/django/core/checks/model_checks.py", line 28, in check_all_models
errors.extend(model.check(**kwargs))
File "/Users/Bren/Desktop/fss/venv/lib/python2.7/site-packages/django/db/models/base.py", line 1205, in check
errors.extend(cls._check_fields(**kwargs))
File "/Users/Bren/Desktop/fss/venv/lib/python2.7/site-packages/django/db/models/base.py", line 1282, in _check_fields
errors.extend(field.check(**kwargs))
File "/Users/Bren/Desktop/fss/venv/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 934, in check
errors = super(AutoField, self).check(**kwargs)
File "/Users/Bren/Desktop/fss/venv/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 207, in check
errors.extend(self._check_backend_specific_checks(**kwargs))
File "/Users/Bren/Desktop/fss/venv/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 306, in _check_backend_specific_checks
return connection.validation.check_field(self, **kwargs)
File "/Users/Bren/Desktop/fss/venv/lib/python2.7/site-packages/django/db/backends/mysql/validation.py", line 18, in check_field
field_type = field.db_type(connection)
File "/Users/Bren/Desktop/fss/venv/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 614, in db_type
return connection.data_types[self.get_internal_type()] % data
File "/Users/Bren/Desktop/fss/venv/lib/python2.7/site-packages/django/db/__init__.py", line 36, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/Users/Bren/Desktop/fss/venv/lib/python2.7/site-packages/django/utils/functional.py", line 59, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Users/Bren/Desktop/fss/venv/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 196, in data_types
if self.features.supports_microsecond_precision:
File "/Users/Bren/Desktop/fss/venv/lib/python2.7/site-packages/django/utils/functional.py", line 59, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Users/Bren/Desktop/fss/venv/lib/python2.7/site-packages/django/db/backends/mysql/features.py", line 52, in supports_microsecond_precision
return self.connection.mysql_version >= (5, 6, 4) and Database.version_info >= (1, 2, 5)
File "/Users/Bren/Desktop/fss/venv/lib/python2.7/site-packages/django/utils/functional.py", line 59, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Users/Bren/Desktop/fss/venv/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 371, in mysql_version
with self.temporary_connection():
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/contextlib.py", line 17, in __enter__
return self.gen.next()
File "/Users/Bren/Desktop/fss/venv/lib/python2.7/site-packages/django/db/backends/base/base.py", line 462, in temporary_connection
cursor = self.cursor()
File "/Users/Bren/Desktop/fss/venv/lib/python2.7/site-packages/django/db/backends/base/base.py", line 162, in cursor
cursor = self.make_debug_cursor(self._cursor())
File "/Users/Bren/Desktop/fss/venv/lib/python2.7/site-packages/django/db/backends/base/base.py", line 135, in _cursor
self.ensure_connection()
File "/Users/Bren/Desktop/fss/venv/lib/python2.7/site-packages/django/db/backends/base/base.py", line 130, in ensure_connection
self.connect()
File "/Users/Bren/Desktop/fss/venv/lib/python2.7/site-packages/django/db/utils.py", line 98, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/Users/Bren/Desktop/fss/venv/lib/python2.7/site-packages/django/db/backends/base/base.py", line 130, in ensure_connection
self.connect()
File "/Users/Bren/Desktop/fss/venv/lib/python2.7/site-packages/django/db/backends/base/base.py", line 119, in connect
self.connection = self.get_new_connection(conn_params)
File "/Users/Bren/Desktop/fss/venv/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 276, in get_new_connection
conn = Database.connect(**conn_params)
File "/Users/Bren/Desktop/fss/venv/lib/python2.7/site-packages/MySQLdb/__init__.py", line 81, in Connect
return Connection(*args, **kwargs)
File "/Users/Bren/Desktop/fss/venv/lib/python2.7/site-packages/MySQLdb/connections.py", line 193, in __init__
super(Connection, self).__init__(*args, **kwargs2)
django.db.utils.OperationalError: (2026, 'SSL connection error: error:00000001:lib(0):func(0):reason(1)')
I reverted my MySql to 5.6.27. Then it worked.

Unhandled exception in thread started

When i run project i get this error in module init.py of Mysqldb at line from MySQLdb.connections import Connection.
What is the meaning of this error, and how do I fix it?. Python 3.4 (64x), Django, Connector and Mysqldb are installed.
def Connect(*args, **kwargs):
from MySQLdb.connections import Connection
return Connection(*args, **kwargs)
Console log:
Unhandled exception in thread started by <pydev_monkey._NewThreadStartupWithTrace object at 0x0000000004D682B0>
Traceback (most recent call last):
File "C:\Program Files (x86)\JetBrains\PyCharm 4.5.4\helpers\pydev\pydev_monkey.py", line 427, in __call__
return self.original_func(*self.args, **self.kwargs)
File "C:\Python34\lib\site-packages\django\utils\autoreload.py", line 229, in wrapper
fn(*args, **kwargs)
File "C:\Python34\lib\site-packages\django\core\management\commands\runserver.py", line 114, in inner_run
self.validate(display_num_errors=True)
File "C:\Python34\lib\site-packages\django\core\management\base.py", line 469, in validate
return self.check(app_configs=app_configs, display_num_errors=display_num_errors)
File "C:\Python34\lib\site-packages\django\core\management\base.py", line 482, in check
include_deployment_checks=include_deployment_checks,
File "C:\Python34\lib\site-packages\django\core\checks\registry.py", line 72, in run_checks
new_errors = check(app_configs=app_configs)
File "C:\Python34\lib\site-packages\django\core\checks\model_checks.py", line 28, in check_all_models
errors.extend(model.check(**kwargs))
File "C:\Python34\lib\site-packages\django\db\models\base.py", line 1205, in check
errors.extend(cls._check_fields(**kwargs))
File "C:\Python34\lib\site-packages\django\db\models\base.py", line 1282, in _check_fields
errors.extend(field.check(**kwargs))
File "C:\Python34\lib\site-packages\django\db\models\fields\__init__.py", line 934, in check
errors = super(AutoField, self).check(**kwargs)
File "C:\Python34\lib\site-packages\django\db\models\fields\__init__.py", line 207, in check
errors.extend(self._check_backend_specific_checks(**kwargs))
File "C:\Python34\lib\site-packages\django\db\models\fields\__init__.py", line 306, in _check_backend_specific_checks
return connection.validation.check_field(self, **kwargs)
File "C:\Python34\lib\site-packages\django\db\backends\mysql\validation.py", line 18, in check_field
field_type = field.db_type(connection)
File "C:\Python34\lib\site-packages\django\db\models\fields\__init__.py", line 614, in db_type
return connection.data_types[self.get_internal_type()] % data
File "C:\Python34\lib\site-packages\django\db\__init__.py", line 36, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "C:\Python34\lib\site-packages\django\utils\functional.py", line 59, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Python34\lib\site-packages\django\db\backends\mysql\base.py", line 196, in data_types
if self.features.supports_microsecond_precision:
File "C:\Python34\lib\site-packages\django\utils\functional.py", line 59, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Python34\lib\site-packages\django\db\backends\mysql\features.py", line 52, in supports_microsecond_precision
return self.connection.mysql_version >= (5, 6, 4) and Database.version_info >= (1, 2, 5)
File "C:\Python34\lib\site-packages\django\utils\functional.py", line 59, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Python34\lib\site-packages\django\db\backends\mysql\base.py", line 371, in mysql_version
with self.temporary_connection():
File "C:\Python34\lib\contextlib.py", line 59, in __enter__
return next(self.gen)
File "C:\Python34\lib\site-packages\django\db\backends\base\base.py", line 462, in temporary_connection
cursor = self.cursor()
File "C:\Python34\lib\site-packages\django\db\backends\base\base.py", line 162, in cursor
cursor = self.make_debug_cursor(self._cursor())
File "C:\Python34\lib\site-packages\django\db\backends\base\base.py", line 135, in _cursor
self.ensure_connection()
File "C:\Python34\lib\site-packages\django\db\backends\base\base.py", line 130, in ensure_connection
self.connect()
File "C:\Python34\lib\site-packages\django\db\backends\base\base.py", line 119, in connect
self.connection = self.get_new_connection(conn_params)
File "C:\Python34\lib\site-packages\django\db\backends\mysql\base.py", line 276, in get_new_connection
conn = Database.connect(**conn_params)
File "C:\Python34\lib\site-packages\MySQLdb\__init__.py", line 80, in Connect
from MySQLdb.connections import Connection
File "C:\Python34\lib\site-packages\MySQLdb\connections.py", line 36
raise errorclass, errorvalue
^
SyntaxError: invalid syntax
MySQLdb does not support Python 3.
There are other clients available though.
You can use mysqlclient. Which is a fork of MySQLdb.
The MySQLdb package you are using is not Python 3. It is a Python 2 package. In Python 2 you can raise an error as you see at the bottom of this stack trace. In Python 3 it should be:
raise errorclass(errorvalue)

django 1.8.3 python manage.py migrate Linux [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/Django-1.8.3-py2.7.egg/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/Django-1.8.3-py2.7.egg/django/core/management/__init__.py", line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/Django-1.8.3-py2.7.egg/django/core/management/base.py", line 393, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python2.7/dist-packages/Django-1.8.3-py2.7.egg/django/core/management/base.py", line 443, in execute
self.check()
File "/usr/local/lib/python2.7/dist-packages/Django-1.8.3-py2.7.egg/django/core/management/base.py", line 481, in check
include_deployment_checks=include_deployment_checks,
File "/usr/local/lib/python2.7/dist-packages/Django-1.8.3-py2.7.egg/django/core/checks/registry.py", line 72, in run_checks
new_errors = check(app_configs=app_configs)
File "/usr/local/lib/python2.7/dist-packages/Django-1.8.3-py2.7.egg/django/core/checks/model_checks.py", line 28, in check_all_models
errors.extend(model.check(**kwargs))
File "/usr/local/lib/python2.7/dist-packages/Django-1.8.3-py2.7.egg/django/db/models/base.py", line 1181, in check
errors.extend(cls._check_fields(**kwargs))
File "/usr/local/lib/python2.7/dist-packages/Django-1.8.3-py2.7.egg/django/db/models/base.py", line 1258, in _check_fields
errors.extend(field.check(**kwargs))
File "/usr/local/lib/python2.7/dist-packages/Django-1.8.3-py2.7.egg/django/db/models/fields/__init__.py", line 934, in check
errors = super(AutoField, self).check(**kwargs)
File "/usr/local/lib/python2.7/dist-packages/Django-1.8.3-py2.7.egg/django/db/models/fields/__init__.py", line 207, in check
errors.extend(self._check_backend_specific_checks(**kwargs))
File "/usr/local/lib/python2.7/dist-packages/Django-1.8.3-py2.7.egg/django/db/models/fields/__init__.py", line 306, in _check_backend_specific_checks
return connection.validation.check_field(self, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/Django-1.8.3-py2.7.egg/django/db/backends/mysql/validation.py", line 18, in check_field
field_type = field.db_type(connection)
File "/usr/local/lib/python2.7/dist-packages/Django-1.8.3-py2.7.egg/django/db/models/fields/__init__.py", line 614, in db_type
return connection.data_types[self.get_internal_type()] % data
File "/usr/local/lib/python2.7/dist-packages/Django-1.8.3-py2.7.egg/django/db/__init__.py", line 36, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/usr/local/lib/python2.7/dist-packages/Django-1.8.3-py2.7.egg/django/utils/functional.py", line 60, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/usr/local/lib/python2.7/dist-packages/Django-1.8.3-py2.7.egg/django/db/backends/mysql/base.py", line 196, in data_types
if self.features.supports_microsecond_precision:
File "/usr/local/lib/python2.7/dist-packages/Django-1.8.3-py2.7.egg/django/utils/functional.py", line 60, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/usr/local/lib/python2.7/dist-packages/Django-1.8.3-py2.7.egg/django/db/backends/mysql/features.py", line 52, in supports_microsecond_precision
return self.connection.mysql_version >= (5, 6, 4) and Database.version_info >= (1, 2, 5)
File "/usr/local/lib/python2.7/dist-packages/Django-1.8.3-py2.7.egg/django/utils/functional.py", line 60, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/usr/local/lib/python2.7/dist-packages/Django-1.8.3-py2.7.egg/django/db/backends/mysql/base.py", line 371, in mysql_version
with self.temporary_connection():
File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
return self.gen.next()
File "/usr/local/lib/python2.7/dist-packages/Django-1.8.3-py2.7.egg/django/db/backends/base/base.py", line 462, in temporary_connection
cursor = self.cursor()
File "/usr/local/lib/python2.7/dist-packages/Django-1.8.3-py2.7.egg/django/db/backends/base/base.py", line 162, in cursor
cursor = self.make_debug_cursor(self._cursor())
File "/usr/local/lib/python2.7/dist-packages/Django-1.8.3-py2.7.egg/django/db/backends/base/base.py", line 135, in _cursor
self.ensure_connection()
File "/usr/local/lib/python2.7/dist-packages/Django-1.8.3-py2.7.egg/django/db/backends/base/base.py", line 130, in ensure_connection
self.connect()
File "/usr/local/lib/python2.7/dist-packages/Django-1.8.3-py2.7.egg/django/db/utils.py", line 97, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/local/lib/python2.7/dist-packages/Django-1.8.3-py2.7.egg/django/db/backends/base/base.py", line 130, in ensure_connection
self.connect()
File "/usr/local/lib/python2.7/dist-packages/Django-1.8.3-py2.7.egg/django/db/backends/base/base.py", line 119, in connect
self.connection = self.get_new_connection(conn_params)
File "/usr/local/lib/python2.7/dist-packages/Django-1.8.3-py2.7.egg/django/db/backends/mysql/base.py", line 276, in get_new_connection
conn = Database.connect(**conn_params)
File "/usr/lib/python2.7/dist-packages/MySQLdb/__init__.py", line 81, in Connect
return Connection(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 187, in __init__
super(Connection, self).__init__(*args, **kwargs2)
django.db.utils.OperationalError: (1049, "Unknown database '/home/workspace/django/mysite/db.mysql'")
and my database setting in settings.py is
'ENGINE': 'django.db.backends.mysql',
'NAME':os.path.join(BASE_DIR, 'jangoo'), #<--idk what to type here
'USER':'root', #I created a database
'PASSWORD':'1234', # named jangoo in mysql
'HOST':'127.0.0.1'
name in db settings most be name of db
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'test',
'USER': 'root',
'PASSWORD': '123567',
'HOST': 'localhost', # Or an IP Address that your DB is hosted on
'PORT': '3306',
'OPTIONS': {"init_command": "SET storage_engine=MyISAM"},
}
}

Socorro - django.db.utils.OperationalError: unable to open database file

I am trying to install Socorro on fresh Ubuntu 10.04 (Amazon EC2). I am following this manual and I am on the step 6.2.8, and I am having a problem with following command:
./manage.py syncdb --noinput
This is the error:
django.db.utils.OperationalError: unable to open database file
What seems to be the problem?
And this is the hole log:
Syncing...
Raven is not configured (logging is disabled). Please see the documentation for more information.
Traceback (most recent call last):
File "./manage.py", line 13, in <module>
manage.main()
File "/etc/socorro/socorro-virtualenv/local/lib/python2.7/site-packages/funfactory/manage.py", line 144, in main
execute_from_command_line(argv)
File "/etc/socorro/socorro-virtualenv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/etc/socorro/socorro-virtualenv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/etc/socorro/socorro-virtualenv/local/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
self.execute(*args, **options.__dict__)
File "/etc/socorro/socorro-virtualenv/local/lib/python2.7/site-packages/django/core/management/base.py", line 285, in execute
output = self.handle(*args, **options)
File "/etc/socorro/socorro-virtualenv/local/lib/python2.7/site-packages/django/core/management/base.py", line 415, in handle
return self.handle_noargs(**options)
File "/etc/socorro/socorro-virtualenv/local/lib/python2.7/site-packages/south/management/commands/syncdb.py", line 92, in handle_noargs
syncdb.Command().execute(**options)
File "/etc/socorro/socorro-virtualenv/local/lib/python2.7/site-packages/raven/contrib/django/management/__init__.py", line 37, in new_execute
return original_func(self, *args, **kwargs)
File "/etc/socorro/socorro-virtualenv/local/lib/python2.7/site-packages/django/core/management/base.py", line 285, in execute
output = self.handle(*args, **options)
File "/etc/socorro/socorro-virtualenv/local/lib/python2.7/site-packages/django/core/management/base.py", line 415, in handle
return self.handle_noargs(**options)
File "/etc/socorro/socorro-virtualenv/local/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 57, in handle_noargs
cursor = connection.cursor()
File "/etc/socorro/socorro-virtualenv/local/lib/python2.7/site-packages/django/db/backends/__init__.py", line 160, in cursor
cursor = self.make_debug_cursor(self._cursor())
File "/etc/socorro/socorro-virtualenv/local/lib/python2.7/site-packages/django/db/backends/__init__.py", line 132, in _cursor
self.ensure_connection()
File "/etc/socorro/socorro-virtualenv/local/lib/python2.7/site-packages/django/db/backends/__init__.py", line 127, in ensure_connection
self.connect()
File "/etc/socorro/socorro-virtualenv/local/lib/python2.7/site-packages/django/db/utils.py", line 99, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/etc/socorro/socorro-virtualenv/local/lib/python2.7/site-packages/django/db/backends/__init__.py", line 127, in ensure_connection
self.connect()
File "/etc/socorro/socorro-virtualenv/local/lib/python2.7/site-packages/django/db/backends/__init__.py", line 115, in connect
self.connection = self.get_new_connection(conn_params)
File "/etc/socorro/socorro-virtualenv/local/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py", line 347, in get_new_connection
conn = Database.connect(**conn_params)
django.db.utils.OperationalError: unable to open database file

Categories

Resources