flask-mysql
flask-mysql copied to clipboard
How replace mysql.connection.commit in this version?
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
same here
can you pls upload more info? Try to include the error traceback.
same here
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()