Create
For the example we will use the following SQLAlchemy model definition.
class User(Base):
__tablename__ = "user"
id: Mapped[int] = mapped_column(primary_key=True)
name: Mapped[str] = mapped_column(nullable=False)
age: Mapped[int] = mapped_column()
date_of_birth: Mapped[date] = mapped_column(nullable=False)
address: Mapped[str] = mapped_column(nullable=False)
Records are created by sending a POST
request with a json
in the payload using the name of the columns as keys, example values:
{
"name": "John",
"age": 18,
"date_of_birth": "2000-01-01",
"address": "Street 1"
}
curl -X 'POST' \
'http://<hostname>/<mount_path>/' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"name": "John",
"age": 18,
"date_of_birth": "2000-01-01",
"address": "Street 1"
}'
json
format, example response:
{
"id": 1,
"name": "John",
"age": 18,
"date_of_birth": "2000-01-01",
"address": "Street 1"
}