Skip to content

Commit

Permalink
add function to delete a site
Browse files Browse the repository at this point in the history
  • Loading branch information
rachel-labri-tipton committed Oct 13, 2023
1 parent 1ec29bc commit 7eb37cd
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions src/get_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,3 +309,56 @@ def create_user(
session.commit()

return user

# delete a site
def delete_site(session: Session, site_uuid: str) -> SiteGroupSQL:
"""Delete a site group.
:param session: database session
:param site_uuid: unique identifier for site
"""
site = session.query(SiteSQL).filter(SiteSQL.site_uuid == site_uuid).first()

session.delete(site)

message = f"Site with site uuid {site.site_uuid} deleted successfully"

session.commit()

return message

# delete user
def delete_user(session: Session, email: str) -> UserSQL:
"""Delete a user.
:param session: database session
:param email: email of user being deleted
"""
user = session.query(UserSQL).filter(UserSQL.email == email).first()

session.delete(user)

message = f"User with email {user.email} and user uuid {user.user_uuid} deleted successfully"

session.commit()

return message

#delete site group
def delete_site_group(session: Session, site_group_name: str) -> SiteGroupSQL:
"""Delete a site group.
:param session: database session
:param site_group_name: name of site group being deleted
"""
site_group = (
session.query(SiteGroupSQL)
.filter(SiteGroupSQL.site_group_name == site_group_name)
.first()
)

session.delete(site_group)

message = f"Site group with name {site_group.site_group_name} and site group uuid {site_group.site_group_uuid} deleted successfully"

session.commit()

return message

0 comments on commit 7eb37cd

Please sign in to comment.