Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><a href="https://docs.djangoproject.com/en/dev/ref/databases/#mysql-notes" rel="noreferrer">MySQL support</a> is simple to add. In your <code>DATABASES</code> dictionary, you will have an entry like this:</p> <pre><code>DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'DB_NAME', 'USER': 'DB_USER', 'PASSWORD': 'DB_PASSWORD', 'HOST': 'localhost', # Or an IP Address that your DB is hosted on 'PORT': '3306', } } </code></pre> <p>You also have the option of utilizing MySQL <a href="https://docs.djangoproject.com/en/1.7/ref/databases/#connecting-to-the-database" rel="noreferrer">option files</a>, as of Django 1.7. You can accomplish this by setting your <code>DATABASES</code> array like so:</p> <pre><code>DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'OPTIONS': { 'read_default_file': '/path/to/my.cnf', }, } } </code></pre> <p>You also need to create the <code>/path/to/my.cnf</code> file with similar settings from above</p> <pre><code>[client] database = DB_NAME host = localhost user = DB_USER password = DB_PASSWORD default-character-set = utf8 </code></pre> <p>With this new method of connecting in Django 1.7, it is important to know the order connections are established:</p> <pre class="lang-none prettyprint-override"><code>1. OPTIONS. 2. NAME, USER, PASSWORD, HOST, PORT 3. MySQL option files. </code></pre> <blockquote> <p>In other words, if you set the name of the database in OPTIONS, this will take precedence over NAME, which would override anything in a MySQL option file.</p> </blockquote> <hr> <p>If you are just testing your application on your local machine, you can use</p> <pre><code>python manage.py runserver </code></pre> <p>Adding the <code>ip:port</code> argument allows machines other than your own to access your development application. Once you are ready to deploy your application, I recommend taking a look at the chapter on <a href="http://www.djangobook.com/en/2.0/chapter12.html" rel="noreferrer">Deploying Django</a> on the <a href="http://www.djangobook.com/en/2.0/index.html" rel="noreferrer">djangobook</a></p> <p>Mysql default character set is often not utf-8, therefore make sure to create your database using this sql: </p> <pre><code>CREATE DATABASE mydatabase CHARACTER SET utf8 COLLATE utf8_bin </code></pre> <p>If you are using <a href="http://dev.mysql.com/doc/connector-python/en/connector-python-django-backend.html" rel="noreferrer">Oracle's MySQL connector</a> your <code>ENGINE</code> line should look like this:</p> <pre><code>'ENGINE': 'mysql.connector.django', </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload