## Hello, I got an error on line 11 when I run this:
import mysql.connector
try:
conn = mysql.connector.connect\
(host='localhost',
database='newbase',
user='root',
password='pwwwwwww#')
#Creating a cursor object using the cursor() method
cursor = conn.cursor() ########## this causes trouble #############
#Dropping EMPLOYEE table if already exists.
cursor.execute("DROP TABLE IF EXISTS EMPLOYEE")
#Creating table as per requirement
sql ='''CREATE TABLE EMPLOYEE(
FIRST_NAME CHAR(20) NOT NULL,
LAST_NAME CHAR(20),
AGE INT,
SEX CHAR(1),
INCOME FLOAT
)'''
cursor.execute(sql)
#Closing the connection
conn.close()
######################################## on Console :
File "/home/charger/PycharmProjects/neu1/testmy.py", line 11
cursor = conn.cursor()
^
SyntaxError: invalid syntax
Process finished with exit code 1
##########################################
who can help me please?
import mysql.connector
try:
conn = mysql.connector.connect\
(host='localhost',
database='newbase',
user='root',
password='pwwwwwww#')
#Creating a cursor object using the cursor() method
cursor = conn.cursor() ########## this causes trouble #############
#Dropping EMPLOYEE table if already exists.
cursor.execute("DROP TABLE IF EXISTS EMPLOYEE")
#Creating table as per requirement
sql ='''CREATE TABLE EMPLOYEE(
FIRST_NAME CHAR(20) NOT NULL,
LAST_NAME CHAR(20),
AGE INT,
SEX CHAR(1),
INCOME FLOAT
)'''
cursor.execute(sql)
#Closing the connection
conn.close()
######################################## on Console :
File "/home/charger/PycharmProjects/neu1/testmy.py", line 11
cursor = conn.cursor()
^
SyntaxError: invalid syntax
Process finished with exit code 1
##########################################
who can help me please?