Connection mysql to Django-python - python

when I am trying to connect MySQL to python Django framework for accessing the database,and running the command python manage.py syncdb ,I get following errors. I have created database name mysite and changed into setting like this:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'mysite',
'USER':'root',
'PASSWORD':'sobita1',
'HOST':'',
'PORT':'',
}
}
Traceback:
python manage.py syncdb
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/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 242, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 285, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 415, in handle
return self.handle_noargs(**options)
File "/usr/local/lib/python2.7/dist- packages/django/core/management/commands/syncdb.py", line 57, in handle_noargs
cursor = connection.cursor()
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 160, in cursor
cursor = self.make_debug_cursor(self._cursor())
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 132, in _cursor
self.ensure_connection()
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 127, in ensure_connection
self.connect()
File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 99, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 127, in ensure_connection
self.connect()
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py", line 115, in connect
self.connection = self.get_new_connection(conn_params)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/mysql/base.py", line 435, 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: (1045, "Access denied for user 'root'#'localhost' (using password: YES)")

I had a similar error:
super(Connection, self).init(*args, **kwargs2)
django.db.utils.OperationalError: (1045, "Access denied for user 'root'#'localhost' (using password: YES)")
To solve it:
1) I removed the Password that I gave, but again I got error like this:
File "C:\Users\Rooman\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\backends\mysql\operations.py", line 146, in last_executed_query
query = query.encode(errors='replace')
AttributeError: 'bytes' object has no attribute 'encode'
2) In the operations.py use decode instead of encode
query = query.decode(errors='replace')
3) Finally run the commands:
python manage.py makemigrations
python manage.py migrate
python manage.py runserver

you are providing a wrong username or password for the database

Related

FATAL: password authentication failed for user "postgres" while running makemigrations

getting the below error while running makemigrations
Traceback (most recent call last):
File "/home/siva/venv/lib/python3.8/site-packages/django/db/backends/base/base.py", line 217, in ensure_connection
self.connect()
File "/home/siva/venv/lib/python3.8/site-packages/django/db/backends/base/base.py", line 195, in connect
self.connection = self.get_new_connection(conn_params)
File "/home/siva/venv/lib/python3.8/site-packages/django/db/backends/postgresql/base.py", line 178, in get_new_connection
connection = Database.connect(**conn_params)
File "/home/siva/venv/lib/python3.8/site-packages/psycopg2/init.py", line 127, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: FATAL: password authentication failed for user "postgres"
FATAL: password authentication failed for user "postgres"
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "/home/siva/venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/home/siva/venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/siva/venv/lib/python3.8/site-packages/django/core/management/base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/siva/venv/lib/python3.8/site-packages/django/core/management/base.py", line 364, in execute
output = self.handle(*args, **options)
File "/home/siva/venv/lib/python3.8/site-packages/django/core/management/base.py", line 83, in wrapped
res = handle_func(*args, **kwargs)
File "/home/siva/venv/lib/python3.8/site-packages/django/core/management/commands/makemigrations.py", line 101, in handle
loader.check_consistent_history(connection)
File "/home/siva/venv/lib/python3.8/site-packages/django/db/migrations/loader.py", line 283, in check_consistent_history
applied = recorder.applied_migrations()
File "/home/siva/venv/lib/python3.8/site-packages/django/db/migrations/recorder.py", line 73, in applied_migrations
if self.has_table():
File "/home/siva/venv/lib/python3.8/site-packages/django/db/migrations/recorder.py", line 56, in has_table
return self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor())
File "/home/siva/venv/lib/python3.8/site-packages/django/db/backends/base/base.py", line 256, in cursor
return self._cursor()
File "/home/siva/venv/lib/python3.8/site-packages/django/db/backends/base/base.py", line 233, in _cursor
self.ensure_connection()
File "/home/siva/venv/lib/python3.8/site-packages/django/db/backends/base/base.py", line 217, in ensure_connection
self.connect()
File "/home/siva/venv/lib/python3.8/site-packages/django/db/utils.py", line 89, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/siva/venv/lib/python3.8/site-packages/django/db/backends/base/base.py", line 217, in ensure_connection
self.connect()
File "/home/siva/venv/lib/python3.8/site-packages/django/db/backends/base/base.py", line 195, in connect
self.connection = self.get_new_connection(conn_params)
File "/home/siva/venv/lib/python3.8/site-packages/django/db/backends/postgresql/base.py", line 178, in get_new_connection
connection = Database.connect(**conn_params)
File "/home/siva/venv/lib/python3.8/site-packages/psycopg2/__init__.py", line 127, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError: FATAL: password authentication failed for user "postgres"
FATAL: password authentication failed for user "postgres"
code in my settings file to import
try:
from .local_settings import *
except ImportError:
pass
Did you check your settings.py DATABASES dict?
It should contain your password as a string, so including quotation marks ('').

After connecting to remote database, migrating gives error: Errno61, Connection Refused

I recently started using sql and connected to an remote sql server. I can run queries on it in python shell and get correct results. However, when I run
manage.py runserver
It tells me that there I need to migrate, however when I migrate I get an error saying:
django.db.utils.OperationalError: (2003, "Can't connect to MySQL server on '*host*' ([Errno 61] Connection refused)")
What should I do to fix this error.
setting.py database:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': '*name*',
'USER': '*user*',
'PASSWORD': '********',
'HOST': '*host*',
'PORT': '****',
'OPTIONS': {
'sql_mode': 'traditional',
}
}
}
full error list here:
File "/Users/lwyss/PycharmProjects/NewWebsite/lib/python3.7/site-packages/pymysql/connections.py", line 583, in connect
**kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socket.py", line 727, in create_connection
raise err
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socket.py", line 716, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 61] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/lwyss/PycharmProjects/NewWebsite/lib/python3.7/site-packages/django/db/backends/base/base.py", line 217, in ensure_connection
self.connect()
File "/Users/lwyss/PycharmProjects/NewWebsite/lib/python3.7/site-packages/django/db/backends/base/base.py", line 195, in connect
self.connection = self.get_new_connection(conn_params)
File "/Users/lwyss/PycharmProjects/NewWebsite/lib/python3.7/site-packages/django/db/backends/mysql/base.py", line 233, in get_new_connection
return Database.connect(**conn_params)
File "/Users/lwyss/PycharmProjects/NewWebsite/lib/python3.7/site-packages/pymysql/__init__.py", line 94, in Connect
return Connection(*args, **kwargs)
File "/Users/lwyss/PycharmProjects/NewWebsite/lib/python3.7/site-packages/pymysql/connections.py", line 325, in __init__
self.connect()
File "/Users/lwyss/PycharmProjects/NewWebsite/lib/python3.7/site-packages/pymysql/connections.py", line 630, in connect
raise exc
pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'masspike.ctqk1lhawxna.us-west-2.rds.amazonaws.com' ([Errno 61] Connection refused)")
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "/Users/lwyss/PycharmProjects/NewWebsite/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/Users/lwyss/PycharmProjects/NewWebsite/lib/python3.7/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/lwyss/PycharmProjects/NewWebsite/lib/python3.7/site-packages/django/core/management/base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/lwyss/PycharmProjects/NewWebsite/lib/python3.7/site-packages/django/core/management/base.py", line 361, in execute
self.check()
File "/Users/lwyss/PycharmProjects/NewWebsite/lib/python3.7/site-packages/django/core/management/base.py", line 390, in check
include_deployment_checks=include_deployment_checks,
File "/Users/lwyss/PycharmProjects/NewWebsite/lib/python3.7/site-packages/django/core/management/commands/migrate.py", line 64, in _run_checks
issues = run_checks(tags=[Tags.database])
File "/Users/lwyss/PycharmProjects/NewWebsite/lib/python3.7/site-packages/django/core/checks/registry.py", line 72, in run_checks
new_errors = check(app_configs=app_configs)
File "/Users/lwyss/PycharmProjects/NewWebsite/lib/python3.7/site-packages/django/core/checks/database.py", line 10, in check_database_backends
issues.extend(conn.validation.check(**kwargs))
File "/Users/lwyss/PycharmProjects/NewWebsite/lib/python3.7/site-packages/django/db/backends/mysql/validation.py", line 9, in check
issues.extend(self._check_sql_mode(**kwargs))
File "/Users/lwyss/PycharmProjects/NewWebsite/lib/python3.7/site-packages/django/db/backends/mysql/validation.py", line 13, in _check_sql_mode
with self.connection.cursor() as cursor:
File "/Users/lwyss/PycharmProjects/NewWebsite/lib/python3.7/site-packages/django/db/backends/base/base.py", line 256, in cursor
return self._cursor()
File "/Users/lwyss/PycharmProjects/NewWebsite/lib/python3.7/site-packages/django/db/backends/base/base.py", line 233, in _cursor
self.ensure_connection()
File "/Users/lwyss/PycharmProjects/NewWebsite/lib/python3.7/site-packages/django/db/backends/base/base.py", line 217, in ensure_connection
self.connect()
File "/Users/lwyss/PycharmProjects/NewWebsite/lib/python3.7/site-packages/django/db/utils.py", line 89, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/Users/lwyss/PycharmProjects/NewWebsite/lib/python3.7/site-packages/django/db/backends/base/base.py", line 217, in ensure_connection
self.connect()
File "/Users/lwyss/PycharmProjects/NewWebsite/lib/python3.7/site-packages/django/db/backends/base/base.py", line 195, in connect
self.connection = self.get_new_connection(conn_params)
File "/Users/lwyss/PycharmProjects/NewWebsite/lib/python3.7/site-packages/django/db/backends/mysql/base.py", line 233, in get_new_connection
return Database.connect(**conn_params)
File "/Users/lwyss/PycharmProjects/NewWebsite/lib/python3.7/site-packages/pymysql/__init__.py", line 94, in Connect
return Connection(*args, **kwargs)
File "/Users/lwyss/PycharmProjects/NewWebsite/lib/python3.7/site-packages/pymysql/connections.py", line 325, in __init__
self.connect()
File "/Users/lwyss/PycharmProjects/NewWebsite/lib/python3.7/site-packages/pymysql/connections.py", line 630, in connect
raise exc
The error comes from the MySQLConnector
"Can't connect to MySQL server on 'masspike.ctqk1lhawxna.us-west-2.rds.amazonaws.com' ([Errno 61] Connection refused)"
So this is a networking problem in which your application is unable to establish a TCP connection to your database. Maybe because of a lack of configuration on your RDS instance? wrong hostname? wrong port? firewall (as mentioned by #Willem van Onsem)? Maybe the Amazon AWS guide on connecting to their database service helps you
In any case it has nothing to do with your program code, apart from the connection string if its wrong.

Error while running python manage py migrate

I am new to django, I was running the command
python manage.py migrate
and got this error.
(py1) G:\django\djangoproject1>python manage.py migrate Traceback
(most recent call last): File "manage.py", line 22, in
execute_from_command_line(sys.argv) File "C:\Users\Mahin\Envs\py1\lib\site-packages\django\core\management__init__.py",
line 364, in execute_from_command_line
utility.execute() File "C:\Users\Mahin\Envs\py1\lib\site-packages\django\core\management__init__.py",
line 356, in execute
self.fetch_command(subcommand).run_from_argv(self.argv) File "C:\Users\Mahin\Envs\py1\lib\site-packages\django\core\management\base.py",
line 283, in run_from_argv
self.execute(*args, **cmd_options) File "C:\Users\Mahin\Envs\py1\lib\site-packages\django\core\management\base.py",
line 327, in execute
self.check() File "C:\Users\Mahin\Envs\py1\lib\site-packages\django\core\management\base.py",
line 359, in check
include_deployment_checks=include_deployment_checks, File "C:\Users\Mahin\Envs\py1\lib\site-packages\django\core\management\commands\migrate.py",
line 61, in _run_checks
issues = run_checks(tags=[Tags.database]) File "C:\Users\Mahin\Envs\py1\lib\site-packages\django\core\checks\registry.py",
line 81, in run_checks
new_errors = check(app_configs=app_configs) File "C:\Users\Mahin\Envs\py1\lib\site-packages\django\core\checks\database.py",
line 10, in check_database_backends
issues.extend(conn.validation.check(**kwargs)) File "C:\Users\Mahin\Envs\py1\lib\site-packages\django\db\backends\mysql\validation.py",
line 9, in check
issues.extend(self._check_sql_mode(**kwargs)) File "C:\Users\Mahin\Envs\py1\lib\site-packages\django\db\backends\mysql\validation.py",
line 13, in _check_sql_mode
with self.connection.cursor() as cursor: File "C:\Users\Mahin\Envs\py1\lib\site-packages\django\db\backends\base\base.py",
line 254, in cursor
return self._cursor() File "C:\Users\Mahin\Envs\py1\lib\site-packages\django\db\backends\base\base.py",
line 229, in _cursor
self.ensure_connection() File "C:\Users\Mahin\Envs\py1\lib\site-packages\django\db\backends\base\base.py",
line 213, in ensure_connection
self.connect() File "C:\Users\Mahin\Envs\py1\lib\site-packages\django\db\utils.py", line
94, in exit
six.reraise(dj_exc_type, dj_exc_value, traceback) File "C:\Users\Mahin\Envs\py1\lib\site-packages\django\db\backends\base\base.py",
line 213, in ensure_connection
self.connect() File "C:\Users\Mahin\Envs\py1\lib\site-packages\django\db\backends\base\base.py",
line 189, in connect
self.connection = self.get_new_connection(conn_params) File "C:\Users\Mahin\Envs\py1\lib\site-packages\django\db\backends\mysql\base.py",
line 274, in get_new_connection
conn = Database.connect(**conn_params) File "C:\Users\Mahin\Envs\py1\lib\site-packages\MySQLdb__init__.py", line
84, in Connect
return Connection(*args, **kwargs) File "C:\Users\Mahin\Envs\py1\lib\site-packages\MySQLdb\connections.py",
line 164, in init
super(Connection, self).init(*args, **kwargs2) django.db.utils.OperationalError: (1045, "Access denied for user
'root'#'localhost' (using password: YES)")
Since I should have magically known your settings.py DB config and my post was deleted for not answering the question without "requiring clarification from the asker" I'm reposting to try and help. The default password for root user in a mysql db is "", that is its left blank. Right now there is a mismatch between your db and the configuration you provided in your settings.py file. Go into your dbms and make sure that the setting for the database match the ones you provided in your settings.py.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'DB NAME',
'USER': 'USER NAME',
'PASSWORD':'USER PW',
'HOST' : 'localhost',
}
}
If these match to your db you should be able to now migrate.

Django trying to use wrong Database User

SOLVED: I was using USERNAME, not USER from previously attempting Postgres driver.
I'm trying to connect my django project to an RDS MySQL database. I can connect fine using my credentials in MySQL Workbench and mysql command line.
I've set the AWS Security Group and VPC Security Group with
All traffic | All | All | 0.0.0.0/0
Let's say my credentials are
User: abc
Password: password
When I run python manage.py migrate it is attempting to login with Mike, not abc for some unknown reason (Mike is the Windows User). How do I prevent this? Attached is my settings.py:
# Database
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'playercomp',
'USERNAME': 'abc',
'PASSWORD': 'password',
'HOST': 'xxx.xxx.us-west-2.rds.amazonaws.com',
'PORT': '3306',
}
}
manage.py
#!/usr/bin/env python
try:
import pymysql
pymysql.install_as_MySQLdb()
except ImportError:
print "Failed to import pymysql"
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "playercomp.settings")
try:
from django.core.management import execute_from_command_line
except ImportError:
# The above import may fail for some other reason. Ensure that the
# issue is really that Django is missing to avoid masking other
# exceptions on Python 2.
try:
import django
except ImportError:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
)
raise
execute_from_command_line(sys.argv)
Error Trace:
Traceback (most recent call last):
File "manage.py", line 27, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\Mike\Envs\playercomp\lib\site-packages\django\core\management\__init__.py", line 367, in execute_from_command_line
utility.execute()
File "C:\Users\Mike\Envs\playercomp\lib\site-packages\django\core\management\__init__.py", line 359, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\Mike\Envs\playercomp\lib\site-packages\django\core\management\base.py", line 294, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\Mike\Envs\playercomp\lib\site-packages\django\core\management\base.py", line 342, in execute
self.check()
File "C:\Users\Mike\Envs\playercomp\lib\site-packages\django\core\management\base.py", line 374, in check
include_deployment_checks=include_deployment_checks,
File "C:\Users\Mike\Envs\playercomp\lib\site-packages\django\core\management\commands\migrate.py", line 61, in _run_checks
issues = run_checks(tags=[Tags.database])
File "C:\Users\Mike\Envs\playercomp\lib\site-packages\django\core\checks\registry.py", line 81, in run_checks
new_errors = check(app_configs=app_configs)
File "C:\Users\Mike\Envs\playercomp\lib\site-packages\django\core\checks\database.py", line 10, in check_database_backends
issues.extend(conn.validation.check(**kwargs))
File "C:\Users\Mike\Envs\playercomp\lib\site-packages\django\db\backends\mysql\validation.py", line 9, in check
issues.extend(self._check_sql_mode(**kwargs))
File "C:\Users\Mike\Envs\playercomp\lib\site-packages\django\db\backends\mysql\validation.py", line 13, in _check_sql_mode
with self.connection.cursor() as cursor:
File "C:\Users\Mike\Envs\playercomp\lib\site-packages\django\db\backends\base\base.py", line 231, in cursor
cursor = self.make_debug_cursor(self._cursor())
File "C:\Users\Mike\Envs\playercomp\lib\site-packages\django\db\backends\base\base.py", line 204, in _cursor
self.ensure_connection()
File "C:\Users\Mike\Envs\playercomp\lib\site-packages\django\db\backends\base\base.py", line 199, in ensure_connection
self.connect()
File "C:\Users\Mike\Envs\playercomp\lib\site-packages\django\db\utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "C:\Users\Mike\Envs\playercomp\lib\site-packages\django\db\backends\base\base.py", line 199, in ensure_connection
self.connect()
File "C:\Users\Mike\Envs\playercomp\lib\site-packages\django\db\backends\base\base.py", line 171, in connect
self.connection = self.get_new_connection(conn_params)
File "C:\Users\Mike\Envs\playercomp\lib\site-packages\django\db\backends\mysql\base.py", line 263, in get_new_connection
conn = Database.connect(**conn_params)
File "C:\Users\Mike\Envs\playercomp\lib\site-packages\pymysql\__init__.py", line 90, in Connect
return Connection(*args, **kwargs)
File "C:\Users\Mike\Envs\playercomp\lib\site-packages\pymysql\connections.py", line 688, in __init__
self.connect()
File "C:\Users\Mike\Envs\playercomp\lib\site-packages\pymysql\connections.py", line 906, in connect
self._request_authentication()
File "C:\Users\Mike\Envs\playercomp\lib\site-packages\pymysql\connections.py", line 1114, in _request_authentication
auth_packet = self._read_packet()
File "C:\Users\Mike\Envs\playercomp\lib\site-packages\pymysql\connections.py", line 981, in _read_packet
packet.check_error()
File "C:\Users\Mike\Envs\playercomp\lib\site-packages\pymysql\connections.py", line 393, in check_error
err.raise_mysql_exception(self._data)
File "C:\Users\Mike\Envs\playercomp\lib\site-packages\pymysql\err.py", line 107, in raise_mysql_exception
raise errorclass(errno, errval)
django.db.utils.OperationalError: (1045, u"Access denied for user 'Mike'#'host-yy-yy.zzz.zz.com' (using password: YES)")
I added a field 'USER': 'abc' to the DATABASES default, and that worked.

Django manage.py syncdb Not Working

I am trying to learn django....
I am following a tutorial and got so far as making an app ....so i opened settings.py file, and i made these changes to 'NAME' AND 'ENGINE', according to the tutorial...here:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': '~/django/bin/django_test/storage.db'
}
So later in the tutorial, it says that in order to actually make such a file "storage.db" to do this:
python manage.py syncdb
this was the result:
/Users/angel/django/lib/python2.7/site-packages/Django-1.8.1-py2.7.egg/django/core/management/commands/syncdb.py:24: RemovedInDjango19Warning: The syncdb command will be removed in Django 1.9
warnings.warn("The syncdb command will be removed in Django 1.9", RemovedInDjango19Warning)
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Users/angel/django/lib/python2.7/site-packages/Django-1.8.1-py2.7.egg/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/Users/angel/django/lib/python2.7/site-packages/Django-1.8.1-py2.7.egg/django/core/management/__init__.py", line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/angel/django/lib/python2.7/site-packages/Django-1.8.1-py2.7.egg/django/core/management/base.py", line 390, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/angel/django/lib/python2.7/site-packages/Django-1.8.1-py2.7.egg/django/core/management/base.py", line 441, in execute
output = self.handle(*args, **options)
File "/Users/angel/django/lib/python2.7/site-packages/Django-1.8.1-py2.7.egg/django/core/management/commands/syncdb.py", line 25, in handle
call_command("migrate", **options)
File "/Users/angel/django/lib/python2.7/site-packages/Django-1.8.1-py2.7.egg/django/core/management/__init__.py", line 120, in call_command
return command.execute(*args, **defaults)
File "/Users/angel/django/lib/python2.7/site-packages/Django-1.8.1-py2.7.egg/django/core/management/base.py", line 441, in execute
output = self.handle(*args, **options)
File "/Users/angel/django/lib/python2.7/site-packages/Django-1.8.1-py2.7.egg/django/core/management/commands/migrate.py", line 93, in handle
executor = MigrationExecutor(connection, self.migration_progress_callback)
File "/Users/angel/django/lib/python2.7/site-packages/Django-1.8.1-py2.7.egg/django/db/migrations/executor.py", line 19, in __init__
self.loader = MigrationLoader(self.connection)
File "/Users/angel/django/lib/python2.7/site-packages/Django-1.8.1-py2.7.egg/django/db/migrations/loader.py", line 47, in __init__
self.build_graph()
File "/Users/angel/django/lib/python2.7/site-packages/Django-1.8.1-py2.7.egg/django/db/migrations/loader.py", line 180, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "/Users/angel/django/lib/python2.7/site-packages/Django-1.8.1-py2.7.egg/django/db/migrations/recorder.py", line 59, in applied_migrations
self.ensure_schema()
File "/Users/angel/django/lib/python2.7/site-packages/Django-1.8.1-py2.7.egg/django/db/migrations/recorder.py", line 49, in ensure_schema
if self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor()):
File "/Users/angel/django/lib/python2.7/site-packages/Django-1.8.1-py2.7.egg/django/db/backends/base/base.py", line 162, in cursor
cursor = self.make_debug_cursor(self._cursor())
File "/Users/angel/django/lib/python2.7/site-packages/Django-1.8.1-py2.7.egg/django/db/backends/base/base.py", line 135, in _cursor
self.ensure_connection()
File "/Users/angel/django/lib/python2.7/site-packages/Django-1.8.1-py2.7.egg/django/db/backends/base/base.py", line 130, in ensure_connection
self.connect()
File "/Users/angel/django/lib/python2.7/site-packages/Django-1.8.1-py2.7.egg/django/db/utils.py", line 97, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/Users/angel/django/lib/python2.7/site-packages/Django-1.8.1-py2.7.egg/django/db/backends/base/base.py", line 130, in ensure_connection
self.connect()
File "/Users/angel/django/lib/python2.7/site-packages/Django-1.8.1-py2.7.egg/django/db/backends/base/base.py", line 119, in connect
self.connection = self.get_new_connection(conn_params)
File "/Users/angel/django/lib/python2.7/site-packages/Django-1.8.1-py2.7.egg/django/db/backends/sqlite3/base.py", line 204, in get_new_connection
conn = Database.connect(**conn_params)
django.db.utils.OperationalError: unable to open database file>
The ~ sign is not expanded to you home dir so you have to manually pass the full absolute path to the database:
'NAME': '/home/yourname/django/bin/django_test/storage.db'
If django_test is the name of your django project then it is better to use the following code:
'NAME': os.path.join(BASE_DIR, 'storage.db'),

Categories