Re: django.db.utils.DatabaseError: (1046, 'No database selected')

2012-12-23 Thread Praveenkumar Venkatesan
Thanks mate. This was a great reply.

-Praveen

On Sunday, December 23, 2012 8:00:51 AM UTC-8, Ramiro Morales wrote:
>
> On Sun, Dec 23, 2012 at 12:59 PM, Ramiro Morales 
> <cra...@gmail.com> 
> wrote: 
> > On Sun, Dec 23, 2012 at 6:45 AM, Praveenkumar Venkatesan 
> > <prave...@gmail.com > wrote: 
> >> Hey All, 
> >> 
> >> I was walking through the tutorial part 1 on polls. When i executed 
> "python 
> >> manage.py sql polls" i got this stack trace 
> >> 
> >> Traceback (most recent call last): 
> >>  [...] 
> >> django.db.utils.DatabaseError: (1046, 'No database selected') 
> >> 
> >> I've been googling and everyone says that i don't have access to the 
> mysql 
> >> database for "polls" but i was able to access the database when i 
> entered 
> >> mysql -u root -h localhost polls 
> >> 
> >> This is how my settings.py looks like for database: 
> >> 
> >> DATABASES = { 
> >> 'default': { 
> >> 'ENGINE': 'django.db.backends.mysql', # Add 
> 'postgresql_psycopg2', 
> >> 'mysql', 'sqlite3' or 'oracle'. 
> >> 'NAME': '',  # Or path to database file if 
> using sqlite3. 
> > 
> > It sems you have correctly created a MySQL database, you've given it 
> > the name 'test' and you've verified it exist adn can be used. Good. 
> > 
> > You've also provided Django presumably the right server name (localhost) 
> > and credentials (root/empty) so it can access such database. Great. 
> > 
> > But there is a crucial link missing. You haven't told Django you want it 
> to use 
> > that database fotr this project/application. 
> > 
> > That's what the NAME setting above is for. Use it. 
>
> Forgot to say that this is clearly derscribed in the relevant tutorial 
> section: 
>
> https://docs.djangoproject.com/en/1.4/intro/tutorial01/#database-setup 
>
> -- 
> Ramiro Morales 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/w-6clyjn_mgJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



django.db.utils.DatabaseError: (1046, 'No database selected')

2012-12-23 Thread Praveenkumar Venkatesan
Hey All,

I was walking through the tutorial part 1 on polls. When i executed "*python 
manage.py sql polls*" i got this stack trace
*
*
*Traceback (most recent call last):*
*  File "manage.py", line 10, in *
*execute_from_command_line(sys.argv)*
*  File 
"/Library/Python/2.7/site-packages/django/core/management/__init__.py", 
line 443, in execute_from_command_line*
*utility.execute()*
*  File 
"/Library/Python/2.7/site-packages/django/core/management/__init__.py", 
line 382, in execute*
*self.fetch_command(subcommand).run_from_argv(self.argv)*
*  File "/Library/Python/2.7/site-packages/django/core/management/base.py", 
line 196, in run_from_argv*
*self.execute(*args, **options.__dict__)*
*  File "/Library/Python/2.7/site-packages/django/core/management/base.py", 
line 232, in execute*
*output = self.handle(*args, **options)*
*  File "/Library/Python/2.7/site-packages/django/core/management/base.py", 
line 304, in handle*
*app_output = self.handle_app(app, **options)*
*  File 
"/Library/Python/2.7/site-packages/django/core/management/commands/sql.py", 
line 19, in handle_app*
*return u'\n'.join(sql_create(app, self.style, 
connections[options.get('database')])).encode('utf-8')*
*  File "/Library/Python/2.7/site-packages/django/core/management/sql.py", 
line 26, in sql_create*
*tables = connection.introspection.table_names()*
*  File "/Library/Python/2.7/site-packages/django/db/backends/__init__.py", 
line 910, in table_names*
*return self.get_table_list(cursor)*
*  File 
"/Library/Python/2.7/site-packages/django/db/backends/mysql/introspection.py", 
line 33, in get_table_list*
*cursor.execute("SHOW TABLES")*
*  File "/Library/Python/2.7/site-packages/django/db/backends/util.py", 
line 40, in execute*
*return self.cursor.execute(sql, params)*
*  File 
"/Library/Python/2.7/site-packages/django/db/backends/mysql/base.py", line 
114, in execute*
*return self.cursor.execute(query, args)*
*  File 
"/Library/Python/2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.8-intel.egg/MySQLdb/cursors.py",
 
line 202, in execute*
*self.errorhandler(self, exc, value)*
*  File 
"/Library/Python/2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.8-intel.egg/MySQLdb/connections.py",
 
line 36, in defaulterrorhandler*
*raise errorclass, errorvalue*
*django.db.utils.DatabaseError: (1046, 'No database selected')*

I've been googling and everyone says that i don't have access to the mysql 
database for "polls" but i was able to access the database when i entered 
*mysql 
-u root -h localhost polls*

This is how my settings.py looks like for database:

*DATABASES = {*
*'default': {*
*'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 
'mysql', 'sqlite3' or 'oracle'.*
*'NAME': '',  # Or path to database file if 
using sqlite3.*
*'USER': 'root',  # Not used with sqlite3.*
*'PASSWORD': '',  # Not used with sqlite3.*
*'HOST': 'localhost',  # Set to empty string 
for localhost. Not used with sqlite3.*
*'PORT': '',  # Set to empty string for 
default. Not used with sqlite3.*
*}*
*}*

Also, here is to show that i actually selected the database

*mysql> use test*
*Database changed*
*mysql> GRANT ALL ON test.* TO 'testuser'@'localhost';*
*Query OK, 0 rows affected (0.08 sec)*
*
*
*mysql> quit*
*Bye*

my mac has been finicky with databases on RoR and so i am trying to switch 
to django. Does anyone know where the problem is?

-Praveen

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Z_jpiK5Q894J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.