Answer the question
In order to leave comments, you need to log in
How to commit SQL queries in Python DB-API?
Hello!
Downloaded and installed the MySQL-connector/Python driver from Oracle. MySQL installed.
I am doing the following procedure:
import mysql.connector
dbconfig = {
'host' : '127.0.0.1',
'user' : 'root',
'password' : 'PaSsWoRd1234',
'database' : 'database1234'}
conn = mysql.connector.connect(**dbconfig)
_SQL = """INSERT INTO some_table VALUES(NULL, 50)"""
cursor=conn.cursor()
cursor.execute(_SQL)
#Пытаюсь закомитить запрос
cursor.commit()
#ОШИБКА! У cursor нету атрибута commit()
Answer the question
In order to leave comments, you need to log in
The connection is responsible for committing transactions, not the cursorconn.commit()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question