I have an app engine project and I want to use MySQL instance (google cloud platform) to store my datas.
I can connect to my instance by using this tuto.
So now I want to know how to create a model like :
app = Flask(__name__)
db = SQLAlchemy(app)
class Visit(db.Model):
id = db.Column(db.Integer, primary_key=True)
timestamp = db.Column(db.DateTime())
user_ip = db.Column(db.String(46))
def __init__(self, timestamp, user_ip):
self.timestamp = timestamp
self.user_ip = user_ip
And add it in my instance, and if I add a field in my model how to update it with my instance.
Because the model you’re updating is a SQLAlchemy model, updating the code and running the SQLAlchemy.create_all() method should take care of it You can take a look at an example here.
This is also a great answer to a similar question. It explains how and when tables are updated by SQLAlchemy.