—
Import mysql.connector
mydb = mysql.connector.connect(
host="localhost",
user="root",
passwd="",
database="mydatabase"
)
mycursor = mydb.cursor()
sql = """INSERT INTO EMPLOYEE(FIRST_NAME,
LAST_NAME, AGE, SEX, INCOME)
VALUES ('Mac', 'Mohan', 20, 'M', 3000)"""
mycursor.execute(sql)
mydb.commit()
print(mycursor.rowcount, "record inserted.")
mydb.close()
— How can i modify this code to user input given
— Use string formattor, like %s
— I m working now in pymysql .....how can i modify this code to user input given .,,,,,,,,
— cursor.execute("INSERT INTO test VALUES ('Number', %s)", (input(),))
— When we run the code user can given input and store the values in mysql
— Where i place that command??
— pythonres learn basics first