1. MySQL this package has to be installed :write: pip install pymysql on command prompt and to run the MySQL

2. We have to install xampp and start Apache and MySQL and open from browser localhost/phpmyadmin.

3. Connect PyCharm with xampp and create database

import the mysql
# install: mysql-connector-python first connect to the database and then open the cursor,
# create a new var for database and create a database and then execute it
import mysql.connector
conn = mysql.connector.connect(
host="localhost",
user="root",
password="",
)

# below code is to check
if conn.is_connected(): # to check whether database is connected or not
	print("Connected to MySQL")

else:

	print("Connection to MySQL failed")

Create a obj for cursor and open a cursor so that we can create a database

Create a new var where we can store a database with predefined key word 'create database school'

Database creation should be done inside the try and except for error handling

cursorobj = conn.cursor()

if conn.is_connected():

	try:
	    db="create database school"
	    cursorobj.execute(db)
			print("database created")
	except:
		print("databse error....")
	else:
		print("Not connected to MySql, cannot create database ")
	

MySQL Datatypes:

INT: integer 11 digit,

BIGINT: 20 digit,

TEXT:0- 6000 ,

VARCHAR:0 - 255,

LONGTEXT : more than 6000,

DATETIME: yyyy-mm-dd hh mm ss,

TIMESTAMP: current time,

TINYINT: 3 digit,

TIME: hh mm ss,