I am developing an application in Python with Flask and SqlAlchemy, for this the basic operations that are carried out are to create a record, modify it and delete it. To create the record with the following code fragment
...
try:
pp = Persona(ci=ci, ext=ext, primerAp=prap, segundoAp=seap, \
nombres=nom, fecha_nacimiento=fnac) #instaciamos una clase
pp.usuario = 'usario23'
pp.fecha = datetime.now()
pp.estado = 'V'
db.session.add(pp)
db.session.commit()
except(KeyError, TypeError, ValueError):
raise jsonify(resultado='Error')
return jsonify(resultado='Ok', Persona=pp.aJson())
...
I have searched SqlAlchemy's documentation and can not find a way to update an instance of an object, something like db.session.update (pp) db.session.commit ()
Does anyone know how this is done?