Message from Python discussions

November 2018

— Can we use MS-SQL in Python ?

— 

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

— Can you please tell me

— 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

— input()

— 🤷‍♂

— Where i place that command??

— pythonres learn basics first