While trying to connect Python with SQL, it just does not work, with no errors, the execution stops itself, here's the code:
import mysql.connector
def appen():
print('k')
mysq = mysql.connector.connect(user = 'root',passwd = 'manager',host = 'localhost', database = 'krishna')
print('g')
cur = mysq.cursor()
print('h')
for i in range(int(input('How many : '))):
eno = int(input('Eno : '))
enm = input('Name : ')
job = input('Job : ')
mgr = int(input('Mgr : '))
hd = input('Hired date(YYYY-MM-DD) : ')
sal = int(input('Salary : '))
cm = int(input('Comm : '))
dn = int(input('Dn : '))
try:
cur.execute(f"insert into employee values({eno},'{enm}','{job}',{mgr},'{hd}',{sal},{cm},{dn});")
cur.commit()
except:
cur.rollback()
cur.close()
mysq.close()
appen()
the only output I am getting is :
k
The issue was solved by using
use_pure=True
in
mysq.connect(...)
, as written here https://stackoverflow.com/a/79228700/16538566