Skip to content

Commit

Permalink
Merge pull request #8 from igagankalra/patch-1
Browse files Browse the repository at this point in the history
Fix Indentation and DB name for models.py
  • Loading branch information
UAnjali authored Oct 6, 2021
2 parents a63594e + 50853cb commit 2e69c73
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions Examples_from_plants_database/Flask-CORS-Example-1/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
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
Expand Down Expand Up @@ -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,
}

0 comments on commit 2e69c73

Please sign in to comment.