diff --git a/Examples_from_plants_database/Flask-CORS-Example-1/models.py b/Examples_from_plants_database/Flask-CORS-Example-1/models.py index 361638ae..9ea00eb1 100644 --- a/Examples_from_plants_database/Flask-CORS-Example-1/models.py +++ b/Examples_from_plants_database/Flask-CORS-Example-1/models.py @@ -4,10 +4,10 @@ import json from sqlalchemy.sql.schema import PrimaryKeyConstraint -database_name = "plants" +database_name = "plantsdb" # Feel free to remove the password argument from the below format() method database_path = "postgresql://{}:{}@{}/{}".format( - "postgres", "", "localhost:5432", database_name + "postgres", "postgres", "localhost:5432", database_name ) db = SQLAlchemy() @@ -33,32 +33,32 @@ class Plant(db.Model): primary_color = Column(String) -def __init__(self, name, scientific_name, is_poisonous, primary_color): - self.name = name - self.scientific_name = scientific_name - self.is_poisonous = is_poisonous - self.primary_color = primary_color + def __init__(self, name, scientific_name, is_poisonous, primary_color): + self.name = name + self.scientific_name = scientific_name + self.is_poisonous = is_poisonous + self.primary_color = primary_color -def insert(self): - db.session.add(self) - db.session.commit() + def insert(self): + db.session.add(self) + db.session.commit() -def update(self): - db.session.commit() + def update(self): + db.session.commit() -def delete(self): - db.session.delete(self) - db.session.commit() + def delete(self): + db.session.delete(self) + db.session.commit() -def format(self): - return { - "id": self.id, - "name": self.name, - "scientific_name": self.scientific_name, - "is_poisonous": self.is_poisonous, - "primary_color": self.primary_color, - } + def format(self): + return { + "id": self.id, + "name": self.name, + "scientific_name": self.scientific_name, + "is_poisonous": self.is_poisonous, + "primary_color": self.primary_color, + }