Skip to content

Commit 90180f9

Browse files
authored
Merge pull request #52 from tecladocode/bug/fix-code-indentation-sqlalchemy-insert
Fix code indentation in markdown (insert SQLAlchemy)
2 parents 81c4c5a + 221e001 commit 90180f9

File tree

1 file changed

+15
-15
lines changed
  • docs/docs/06_sql_storage_sqlalchemy/05_insert_models_sqlalchemy

1 file changed

+15
-15
lines changed

docs/docs/06_sql_storage_sqlalchemy/05_insert_models_sqlalchemy/README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,21 @@ Similarly in our `Store` resource:
3232

3333
```python title="resources/store.py"
3434
@blp.arguments(StoreSchema)
35-
@blp.response(201, StoreSchema)
36-
def post(self, store_data):
37-
store = StoreModel(**store_data)
38-
try:
39-
db.session.add(store)
40-
db.session.commit()
41-
except IntegrityError:
42-
abort(
43-
400,
44-
message="A store with that name already exists.",
45-
)
46-
except SQLAlchemyError:
47-
abort(500, message="An error occurred creating the store.")
48-
49-
return store
35+
@blp.response(201, StoreSchema)
36+
def post(self, store_data):
37+
store = StoreModel(**store_data)
38+
try:
39+
db.session.add(store)
40+
db.session.commit()
41+
except IntegrityError:
42+
abort(
43+
400,
44+
message="A store with that name already exists.",
45+
)
46+
except SQLAlchemyError:
47+
abort(500, message="An error occurred creating the store.")
48+
49+
return store
5050
```
5151

5252
Note here we're catching two different errors, `IntegrityError` for when a client attempts to create a store with a name that already exists, and `SQLAlchemyError` for anything else.

0 commit comments

Comments
 (0)