0% found this document useful (0 votes)
3 views2 pages

Mysql

This document provides a step-by-step guide on connecting MySQL with Django, including downloading the MySQL installer, creating a database, and installing necessary Python packages. It outlines the installation process, basic MySQL commands for database management, and configuration settings for Django's settings.py file. The document emphasizes the use of 'pymysql' and 'mysql-connector-python' packages to facilitate the connection.

Uploaded by

mamatha071297
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Mysql

This document provides a step-by-step guide on connecting MySQL with Django, including downloading the MySQL installer, creating a database, and installing necessary Python packages. It outlines the installation process, basic MySQL commands for database management, and configuration settings for Django's settings.py file. The document emphasizes the use of 'pymysql' and 'mysql-connector-python' packages to facilitate the connection.

Uploaded by

mamatha071297
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

My Sql

Monday, January 25, 2021 9:13 AM

Connecting MySql with django:


----------------------------
1. Download MySql installer by using below url
https://dev.mysql.com/downloads/installer/
2. once u click on above url it will ask u to create a oracle account create
it by giving some random details
3. after that log in into that and download with default settings
4. while installing it will install the following packages
1. MySQL workbench
2. MySQL commandline client
3. MYSQL installer
4. MySql notifier
5. mysql-installer-web-community

5. After successfull installations search for mysql and click on


mysql commandline client

6. it will ask u to enter password


root (is the password)

7. syntax for creating database


create database databasename;

8. in order to use that created database by using below command


use databasename;

9.syntax to see the tables of Database


show tables;

10. syntax to retrieve the data


select * from Relationname;
Now we have to install Two python packages inorder to connect mysql to ur django
project
1. pip install pymysql
2. pip install mysql-connector-python

Now Configuring with in the settings.py tfile of ur project


-----------------------------------------------------------
import pymysql
pymysql.version_info=(1,4,6,"final",0)
pymysql.install_as_MySQLdb()

#now after this scroll down to database section


DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'name of the database u have created',
'USER':'root',
'PASSWORD':'root',
'HOST':'localhost',
'PORT':3306,
}
}

You might also like