官术网_书友最值得收藏!

Introduction

In the previous chapter, we were only storing our data in application memory. While it is easy to code that way, the data will be gone once the server restarts. That is obviously not ideal because we would expect the data to be persisted even after a server restart or application migration and suchlike. Therefore, in this chapter, we will talk about persisting data in a database. We will begin by installing the Postgres database on our local machine. Then, we will create a database using pgAdmin and interact with it using the ORM (Object Relational Mapping) package, SQLAlchemy. ORM allows us to interact with a database by means of an object instead of an SQL query. After that, we will define the user and recipe models, link them up, and use Flask-Migrate to create the corresponding tables in the database. Once that part is complete, we will go through exercises to understand the utilization of SQLAlchemy in the Python console. Lastly, we will add the resource for users so that new users can be created through an API.

主站蜘蛛池模板: 定结县| 休宁县| 瑞安市| 台湾省| 宁海县| 驻马店市| 酉阳| 呼和浩特市| 甘德县| 莫力| 黑水县| 中宁县| 明溪县| 浦江县| 化德县| 马尔康县| 上饶县| 聂拉木县| 铁岭县| 定边县| 台前县| 天峨县| 旺苍县| 咸丰县| 金阳县| 清远市| 伊通| 荥阳市| 肇东市| 大城县| 丰都县| 井冈山市| 大洼县| 禹城市| 武宁县| 禄丰县| 苏尼特左旗| 蕲春县| 涞源县| 桦川县| 蒲江县|