I tried to summarize the settings for various databases of Django (MySQL, PostgreSQL)

I've put together a summary to make it easier to do when you end up changing the database used by Django. SQLite3

settings.py


DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

MySQL

settings.py


DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'DATABASE',  #Database name
        'USER': 'USER',  #User ID
        'PASSWORD': 'password',  #User ID password
        'HOST': 'localhost',  #hostname
        'PORT': '3306',
    }
}

Required libraries: mysqlclient You can use PyMySQL, but mysqlclient is recommended.

POSTGRESQL

settings.py


DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'DATABASE',  #Database name
        'USER': 'USER',  #User ID
        'PASSWORD': 'password',  #User ID password
        'HOST': 'localhost',  #hostname
        'PORT': '5432',
    }
}

Required library: psycopg2

Recommended Posts

I tried to summarize the settings for various databases of Django (MySQL, PostgreSQL)
I tried to summarize the basic form of GPLVM
I tried to summarize the string operations of Python
[Machine learning] I tried to summarize the theory of Adaboost
[Linux] I tried to summarize the command of resource confirmation system
I tried the asynchronous server of Django 3.0
I tried to summarize the umask command
I tried to summarize the graphical modeling.
I tried to summarize the frequently used implementation method of pytest-mock
I tried to summarize various sentences using the automatic summarization API "summpy"
I tried to summarize the logical way of thinking about object orientation.
I tried to touch the API of ebay
I tried to correct the keystone of the image
LeetCode I tried to summarize the simple ones
I tried to predict the price of ETF
I tried to vectorize the lyrics of Hinatazaka46!
I didn't understand the Resize of TensorFlow so I tried to summarize it visually.
I tried to automate the face hiding work of the coordination image for wear
I tried to summarize how to use matplotlib of python
I tried the MNIST tutorial for beginners of tensorflow.
I tried to visualize the spacha information of VTuber
I tried to erase the negative part of Meros
I tried to classify the voices of voice actors
I tried to summarize SparseMatrix
I tried porting the code written for TensorFlow to Theano
[Horse Racing] I tried to quantify the strength of racehorses
[First COTOHA API] I tried to summarize the old story
I tried to get the location information of Odakyu Bus
I tried to find the average of the sequence with TensorFlow
I tried to summarize the code often used in Pandas
[Python] I tried to visualize the follow relationship of Twitter
I tried to summarize the commands often used in business
I tried to fight the Local Minimum of Goldstein-Price Function
I tried to get various information from the codeforces API
I tried to summarize how to use the EPEL repository again
I forgot to evaluate the performance because of the habit of skipping "I tried to aim for the fastest FizzBuzz"
I tried to move the ball
I tried to estimate the interval.
I tried to get the index of the list using the enumerate function
I tried to automate the watering of the planter with Raspberry Pi
I tried to build the SD boot image of LicheePi Nano
I tried to summarize the commands used by beginner engineers today
I tried to expand the size of the logical volume with LVM
I tried to solve the shift scheduling problem by various methods
I tried to improve the efficiency of daily work with Python
I tried to visualize the common condition of VTuber channel viewers
[Flask] I tried to summarize the "docker-compose configuration" that can be created quickly for web applications
I tried to summarize the contents of each package saved by Python pip in one line
To celebrate the release of Django 3.0, I tried ASGI, the spiritual successor to WSGI, but I couldn't use websocket.
I tried to transform the face image using sparse_image_warp of TensorFlow Addons
Consider the description of Dockerfile (Django + MySQLâ‘¡)
I tried to summarize Python exception handling
I tried to refer to the fun rock-paper-scissors poi for beginners with Python
I tried to summarize until I quit the bank and became an engineer
I tried to get the batting results of Hachinai using image processing
I tried to visualize the age group and rate distribution of Atcoder
I tried tensorflow for the first time
I tried transcribing the news of the example business integration to Amazon Transcribe
I tried to summarize the general flow up to service creation by self-education.
How to check the version of Django
I tried to recognize the wake word