Tuesday, January 28, 2014

Re: moving from sqlite3 to mysql

On Tuesday, January 28, 2014 9:17:32 AM UTC-8, Malik Rumi wrote:
This is somewhat like the question in "need help moving to production server" but I think the right procedure is to start a new thread. So I think I have done well for just starting out. With your help I've gotten Django running on Windows, and I completed a tutorial and got my site working locally with the admin. thank you.

So I thought I was ready to move up to MySQL for some heavy lifting. I followed the instructions I got here http://matthewwittering.com/blog/how-to-migrating-the-database-engine-for-django.html. I did not know what to do with the NAME part, so I put in 'django-1', and promptly got the error message 'unknown database 'django-1'. I thought that made sense because I hadn't created this database in mysql already, but I was just blindly following along. Having to CREATE DATABASE doesn't make sense, I thought, because it defeats the purpose of Django abstraction in the first place. Besides, when I syncdb, it should take whatever name I gave it when I was using sqlite3, right?

Wrong. When I ran syncdb, this time with NAME: ' ', I got :   File "C:\Python27\lib\site-packages\MySQLdb\connections.py", line 36, in default terror handler    raise errorclass, errorvalue django.db.utils.OperationalError: (1046, 'No database selected').

So, what am I missing here? There almost certainly is an easy solution I'm not seeing. Do I need to create a database in mysql? If so, must it have the same name as it had in sqlite3? I know that name was made from putting the model name together with something else, but I don't actually remember what it was, and it seems like a lot of extra work to install an sqlite browser just to get that name right. If that's what I need to do, maybe I can just open that file with notepad? 

Or can I create the database, (presumably directly in the shell), and then empty it, as these instructions say, and that will take care of it? I frankly didn't understand why I would need to 'empty' a new and empty database, but that's what it says. 

Any and all helpful advise welcome and appreciated. 

You should go through the tutorial, which explains how to create a project.

From the database setup page:

"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." 

https://docs.djangoproject.com/en/1.6/intro/tutorial01/#database-setup


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c991d28f-720e-495a-b7ae-3e8d7e52dcef%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment