Sir mysql code type right but not working

import pymysql
def createconn():
return pymysql.connect(host=“localhost”,database=“jaishreeram”,user=“root”,password="",port=3306)

Table create a function

def createTable():
conn =createconn()
cursor =conn.cursor() # helping to excute your quary
query =“Creat table student (sid int primary key auto_increment,name VARCHAR(50),email VARCHAR(50),city VARCHAR(50))”
cursor.execute(query)
conn.commit()
conn.close()
createTable()

Same problem for me sir

Same problem with me

Try using mycursor instead of cursor :
import mysql.connector

def conn():
return mysql.connector.connect(host=“localhost”,database=“python”,user=“root”,password=“password”,port=3306)

def createtable():
con=conn()
mycursor=con.cursor()
query=“create table student2(name varchar(10), clas int,rollno int primary key )”
mycursor.execute(query)
con.commit()
print(“table created”)
con.close()

try this code if you are using pycharm