FastAPI with PostgreSQL Part 1

<p>We continue with the&nbsp;<a href="https://fastapi.tiangolo.com/" rel="noopener ugc nofollow" target="_blank">FastAPI</a>&nbsp;Series and this time we are going to connect our application to a&nbsp;<a href="https://www.postgresql.org/" rel="noopener ugc nofollow" target="_blank">PostgreSQL</a>&nbsp;Database, we are also going to do a couple of tests with&nbsp;<a href="https://docs.pytest.org/en/7.2.x/" rel="noopener ugc nofollow" target="_blank">Pytest</a>, all this on&nbsp;<a href="https://www.docker.com/" rel="noopener ugc nofollow" target="_blank">Docker</a>&nbsp;to have the necessary infrastructure, so, in short, we will see:</p> <ul> <li>API Dockerization.</li> <li>Infrastructure with Docker Compose. (DB &mdash; API)</li> <li><a href="https://sqlmodel.tiangolo.com/" rel="noopener ugc nofollow" target="_blank">SQLModel</a>&nbsp;for tables.</li> <li>Connection with&nbsp;<a href="https://www.postgresql.org/" rel="noopener ugc nofollow" target="_blank">PostgreSQL</a>.</li> <li>Testing with&nbsp;<a href="https://docs.pytest.org/en/7.2.x/" rel="noopener ugc nofollow" target="_blank">Pytest</a>.</li> </ul> <p>The first thing we are going to do is clone our previous&nbsp;<a href="https://github.com/arturocuicas/fastapi_base.git" rel="noopener ugc nofollow" target="_blank">Project</a>&nbsp;and we are going to Dockerize it, for this, we are going to do it in the simplest way possible, in future chapters we will do it&nbsp;<strong><em>multi-staging</em></strong>&nbsp;so that it gets closer to a&nbsp;<strong>Production</strong>&nbsp;image.</p> <p>First of all, we are going to create our&nbsp;<strong><em>Dockerfile</em></strong>&nbsp;file where we are going to indicate the&nbsp;<strong>Python</strong>&nbsp;image that we are going to use and we will install the dependencies through&nbsp;<a href="https://python-poetry.org/" rel="noopener ugc nofollow" target="_blank">Poetry</a>.</p> <p><a href="https://medium.com/@arturocuicas/fastapi-with-postgresql-part-1-70a3960fb6ee"><strong>Click Here</strong></a></p>