wenn ich den Code unten ausführe kommt eine Fehlermeldung, (Zeile 11 ist die Ursache)
wer kann mir helfen?
Code: Alles auswählen
import mysql.connector
try:
conn = mysql.connector.connect\
(host='localhost',
database='newbase',
user='root',
password='Nevada80#')
#Creating a cursor object using the cursor() method
cursor = conn.cursor() ################ Zeile 11, Ursache für den Syntaxfehler #########
#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()
File "/home/cha......../testmy.py", line 11
cursor = conn.cursor()
^
SyntaxError: invalid syntax
Process finished with exit code 1