Skip to content

How do I create a new ORM object with information passed via JSON? #246

@moonman239

Description

@moonman239

I have an ORM class created with SQLAlchemy, example:

class Person(Base):
    name = Column(String,nullable=False)
    birthdate = Column(String,CheckConstraint("birthdate >= '1970-01-01'")
    ssn = Column(String,primary_key=True)

My Flask app will be in charge of retrieving and inserting ORM objects like so:

@app.route("/people/<ssn>/insert",methods=["PUT"])
def insert_person(ssn):
    # insert person into database

The information to be inserted will be provided within the request, via a JSON string, ex:
{"name":"Bobby Burger","ssn":"123-45-6789"}
I already have a schema defined that I won't mention here.

I want to create an ORM object filled with the information provided.
How do I do this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions