Skip to content

Models and Schemas

CRAG666 edited this page Jun 22, 2020 · 8 revisions

Models

Models are made with sqlalchemy(read for more info), the only change from sqlalchemy models is to create a method:

  • changes

The models would look like this:

model

The changes method receives a json as a parameter:

changes

Json key values ​​are assigned to the columns of the database:

fields

Take any action on the data, In the example the password is encrypted

The constructor receives as a parameter a json and call the changes method; this to avoid doing repetitive code

cons

The changes method will serve to insert data in json format both to create a new record (init method) and to modify it (changes method)

Another model example

other

Clone this wiki locally