import mysql.connector #pip3 install mysql-connector-python #pip install mysql #pip install MySQL-python #import MySQLdb try: conn = mysql.connector.connect(host="localhost",user="root",password="sncfp1p2", database="python") cursor = conn.cursor() name = "olivier" id = 5 cursor.execute("""SELECT id, name, age FROM visiteurs WHERE name = %s""", (name, )) rows = cursor.fetchall() for row in rows: print('{0} : {1} - {2}'.format(row[0], row[1], row[2])) #conn.commit() except Exception as e: print("Erreur") conn.rollback() # raise e finally: conn.close()