0
There is a code in the description and this code returns a exception ('str' object is not callable). What does it mean ?
import mysql.connector import sys print("package accepted") try: con=mysql.connector.connect(host="localhost",user="root",password="********",database="emp1",auth_plugin="mysql_native_password") print("connection success") cur=con.cursor() eno=int(input("enter the employee number")) ename=input("enter the employee name") sal=int(input("enter the salary:")) cur.execute("insert into details(eno,ename,sal) values(%d,%s,%d);"(eno,ename,sal)) print("successfully inserted") con.commit() except: print("error name=",sys.exc_info())
2 odpowiedzi
+ 1
That error message happens when you have a string variable and attempt to call it as though it were a function. Example,
test = Hello World"
test() #Error 'str' object is not callable.
Since this error happened when much of the code is in a try: block, I assume the problem is with the line in the except: block. Try removing the parentheses ("(" and ")") after sys.exc_info.
...
except:
print("error name=",sys.exc_info)
0
Bro russ it shows another exception (built in function exc_info)