Forums

I can't insert new registers to mysql from flask-sqlalchemy web app

Hi Team.

I have create a flask web app that it's connected with database mysql by sqlalchemy-flask.

<a href="http://www.freeimagehosting.net/commercial-photography/"><img src="https://i.imgur.com/HOpg7G1.png" alt="Commercial Photography"></a>

I can use <<db.session.execute>> for make a query: "SELECT * FROM USUARIO" (USUARIO is a table in my mysql-database).

But, when i make query: "INSERT INTO ...", i can't view changes in my USUARIO table, but my key primary increase.

<a href="http://www.freeimagehosting.net/commercial-photography/"><img src="https://i.imgur.com/59GbIPD.png" alt="Commercial Photography"></a>

<a href="http://www.freeimagehosting.net/commercial-photography/"><img src="https://i.imgur.com/GbZRZlQ.png" alt="Commercial Photography"></a>

I think that it happend because i don't have permissions for make 'INSERT INTO' from flask-app, but i don't know exactly.

Regards.

Thanks for your attention.

If you do db.session.execute(...), you probably also need to do db.session.commit() afterwards to commit the changes to the database.