user2086641
user2086641

Reputation: 4371

Python/Django installation is not happening

I newly installed python 2.7 and django 1.3.Django 1.3 was insatalled from this comand

yum install Django MySQL-python 

installation was said it is completed sucessfully.But after that i am trying to create a database table using the command

   python manage.py syncdb 

I am getting the following traceback

[root@localhost DemoApp]# python manage.py syncdb
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 429, in execute_from_command_line
    utility.execute()
  File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/python2.7/site-packages/django/core/management/base.py", line 191, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/lib/python2.7/site-packages/django/core/management/base.py", line 219, in execute
    self.validate()
  File "/usr/lib/python2.7/site-packages/django/core/management/base.py", line 249, in validate
    num_errors = get_validation_errors(s, app)
  File "/usr/lib/python2.7/site-packages/django/core/management/validation.py", line 102, in get_validation_errors
    connection.validation.validate_field(e, opts, f)
  File "/usr/lib/python2.7/site-packages/django/db/backends/mysql/validation.py", line 14, in validate_field
    db_version = self.connection.get_server_version()
  File "/usr/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 338, in get_server_version
    self.cursor()
  File "/usr/lib/python2.7/site-packages/django/db/backends/__init__.py", line 250, in cursor
    cursor = self.make_debug_cursor(self._cursor())
  File "/usr/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 322, in _cursor
    self.connection = Database.connect(**kwargs)
  File "/usr/lib/python2.7/site-packages/MySQLdb/__init__.py", line 81, in Connect
    return Connection(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/MySQLdb/connections.py", line 187, in __init__
    super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (1049, "Unknown database 'DemoApp'")

can any one tell me what would be the cause of this problem,any wrong in installation

Upvotes: 0

Views: 489

Answers (1)

Mark Hildreth
Mark Hildreth

Reputation: 43071

According to the Django documentation:

If you’re using PostgreSQL or MySQL, make sure you’ve created a database by this point. Do that with “CREATE DATABASE database_name;” within your database’s interactive prompt.

If you’re using SQLite, you don’t need to create anything beforehand - the database file will be created automatically when it is needed.

So, you need to create the database first to have syncdb load the data.

To create the database, run the mysql program. This gives you a command prompt for interacting with your SQL database. Then you run...

create database DemoApp;

For more info on doing this, see the MySQL tutorial on Connecting and Disconnecting from the Server and Creating and Selecting a Database.

Upvotes: 5

Related Questions