Cannot migrate to MySQL database


I am trying to use MySQL for my website and am experiencing problems migrating to my new db. I would appreciate any help on this.

I have been following instructions from Django Girls <ul> <li>cloning my repository from github and setting up .gitignore to ignore sqlite</li> <li>creating a virtual environment and installing necessary modules (django, mysqlclient, etc.)</li> <li>assigning variables in /var/www/<username></li> <li>exporting variables in myvenv/bin/activate/ (when I do echo $SECRET_KEY the console returns the right value)</li> </ul>

I changed my as follows so that I access sqlite3 only when I am working locally. <pre><code>if os.getenv('DEBUG') == "False": DEBUG = False else: DEBUG = True


if DEBUG == False: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'brianhscho$database', 'USER': 'brianhscho', 'PASSWORD': os.getenv('MYSQL_PASSWORD'), 'HOST': '', } } else: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } } </code></pre> There are no errors in the local server, but when I try to open my website from pythonanywhere I get this error,

<pre><code>2019-02-08 21:42:56,624: File "/usr/lib/python3.6/site-packages/MySQLdb/", line 50, in defaulterrorhandler 2019-02-08 21:42:56,624: raise errorvalue 2019-02-08 21:42:56,624: 2019-02-08 21:42:56,624: File "/usr/lib/python3.6/site-packages/MySQLdb/", line 247, in execute 2019-02-08 21:42:56,624: res = self._query(query) 2019-02-08 21:42:56,624: 2019-02-08 21:42:56,624: File "/usr/lib/python3.6/site-packages/MySQLdb/", line 412, in _query 2019-02-08 21:42:56,624: rowcount = self._do_query(q) 2019-02-08 21:42:56,625: 2019-02-08 21:42:56,625: File "/usr/lib/python3.6/site-packages/MySQLdb/", line 375, in _do_query 2019-02-08 21:42:56,625: db.query(q) 2019-02-08 21:42:56,625: 2019-02-08 21:42:56,625: File "/usr/lib/python3.6/site-packages/MySQLdb/", line 276, in query 2019-02-08 21:42:56,625: _mysql.connection.query(self, query) </code></pre>

When I type in the following in the bash console, <pre><code>(myvenv) 12:39 ~/mysite (master)$ python migrate</code></pre>

I get the following error message, <pre><code> File "/home/brianhscho/mysite/myvenv/lib/python3.6/site-packages/MySQLdb/connections .py", line 217, in query _mysql.connection.query(self, query) django.db.utils.ProgrammingError: (1146, "Table 'brianhscho$database.practice_exam_exa mid' doesn't exist") </code></pre>

ExamID is a table saved in the local db.sqlite3 and defined in I am not sure why these tables are not being migrated to MySQL.

Any help would be appreciated. Thank you so much!

if you have data saved onn your local machine in the local db.sqlite3, that is not accessible from PythonAnywhere. so you would need to create the same table on PythonAnywhere's mysql database before migrating etc.

That makes so much sense - I just remembered one of my model takes a length of another model as value. That was causing the error.

Fixing it solved my problem. Thank you so much!!!

Excellent -- glad we could help!