mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
18 lines
534 B
Python
18 lines
534 B
Python
from sqlalchemy.orm import sessionmaker
|
|
from backend.app.db.connection import db_engine
|
|
from backend.app.db.models.recommendations import Plan
|
|
|
|
|
|
def create_plan(plan):
|
|
"""
|
|
This function will create a record for the plan in the database if it does not exist.
|
|
:param plan: dictionary of data representing a plan to be created
|
|
"""
|
|
|
|
Session = sessionmaker(bind=db_engine)
|
|
with Session() as session:
|
|
new_plan = Plan(**plan)
|
|
session.add(new_plan)
|
|
session.commit()
|
|
|
|
return new_plan.id
|