flask-mysql icon indicating copy to clipboard operation
flask-mysql copied to clipboard

How replace mysql.connection.commit in this version?

Open Salchi12 opened this issue 4 years ago • 4 comments

i try to do a proyect but.....pum!!! this the error that always appear

AttributeError

AttributeError: 'function' object has no attribute 'commit'

if anybody know the solucion please tell me

Salchi12 avatar Mar 25 '20 03:03 Salchi12

same here

AlbertoCrespoGuzman avatar Apr 21 '20 23:04 AlbertoCrespoGuzman

can you pls upload more info? Try to include the error traceback.

luisjimenez6245 avatar Sep 03 '20 17:09 luisjimenez6245

same here

lukahorvat96 avatar Feb 14 '21 14:02 lukahorvat96

I found out the solution "mydb.get_db().commit()".

Example:

app.config['MYSQL_DATABASE_HOST'] = 'localhost'
app.config['MYSQL_DATABASE_USER'] = 'root'
app.config['MYSQL_DATABASE_PASSWORD'] = ''
app.config['MYSQL_DATABASE_DB'] = 'db'
 
mydb = MySQL(app)
mydb.init_app(app)
mycursor = mydb.get_db().cursor()
mycursor.execute(query, values)
mydb.get_db().commit()

lukahorvat96 avatar Feb 14 '21 14:02 lukahorvat96