Simplify your web development with docker and docker-compose
In this article we will cover how to create a python based REST API and utilise docker-compose to improve both development and production. However before you start reading this article, I would recommend understanding how to use python with docker in part-1.
Docker compose is a tool to manage multiple containers in a one YAML file and manage these containers with one command and thus drastically simplifying our development.
In the previous tutorial, we created two containers, a container for python REST API and container for PostgreSQL-DB. We had to build the…
In any web development project, you would usually have many components, a database or multiple databases, a cronjob, a backend, a frontend.. etc. Setting up databases takes time and in case of change for example moving away from Postgres to MariaDB would require uninstalling Postgres and installing MariaDB. Let’s say you are using OSX and your colleagues are using Windows yet the production environment is Linux based. Now you have to ensure that all of your setup works on all three operating systems. This is where docker comes into play and saves us all.
According to the docker documentation
Which package manager to use in 2020?
The majority of developers when they get introduced to python, most probably
pip is first tool they learn to use to manage packages. I have used
pip for the first couple of years working as a developer and at that time there were almost no alternatives until that has changed.
pip comes by default with python and installing packages with
pip is pretty straight-forward,
Just pip it …
$ pip install [package-name]
If you need to keep you packages organised, and you don’t want to install project packages in the user or systems…
The purpose of this article is to create a simple guide on how to use FastAPI with relational databases asynchronously and use Alembic for migrations. Before you go a head with this tutorial please check part-1.
Here is the full working code on github
Install the required package
databases is a lightweight package with asyncio support for many relational databases and uses the
sqlalchemy core queries.
for the purpose of this tutorial I will be using pipenv, but you can use pip or poetry or conda or whatever package manager you like.
pipenv install databases pipenv install databases[postgresql] pipenv…
The easiest way for parsing request payload and query parameters
For a very long time Flask was my first choice of framework when it came to building micro-services (until python 3.6 and async/await came to life). I have used Flask with a different number of extensions depending on the situation.
webargs .. etc. All of these extensions were great until I needed to parse the request payload or query parameters, it gets painful and the reason is they are all built on top of
Marshmallow is probably the oldest python package for object serialisation and parsing…
The easiest way to get corona virus current statistics using python, data is based on John Hopkins University.
The corona virus is spreading in an unexpectedly unstoppable way. There are great efforts being done to stop the spread of this virus. I wanted to be a part of this and do something that might help even a little. So I wrote this package hoping that someone would use it to collect data or make better visualizations … etc.
Full documentation can be found here
Full code on Github can be found here
pip install covid
python >= 3.6
This is my top 10 list of visual studio code extensions in 2020 for python.
Tutorial for Mkdocs with material theme and hosting on github pages
Everyone loves frameworks and packages that have a good documentation. There are a lot of frameworks that I love their documentation, for example Django, React, Angular and many more. However, FastAPI and Pyndatic specially stood out from the rest. It was the documentation that pushed to try out FastAPI from the start. And the best part, it is so easy to create the same documentation unlike the rest.
What the hell is Sanic web framework anyway?
I recently came across Sanic and I was surprised why I never heard about it before. Sanic is a micro-framework which is quite close to Flask. It is quite extensible with a lot of extensions and middleware being created for it. In this article we will discuss the pros and cons of Sanic and we will see in which scenarios Sanic might replace Flask.
At the time this article was written, Sanic on github has around 13.5k stars, 226 contributors and is used by 2.7k …
The comprehensive guide (tutorial) to using relational databases with FastAPI
The purpose of this article is to create a simple guide on how to use FastAPI with relational databases and use Alembic for migrations. An implementation that can be used in production
I will be using
pipenv to manage both my packages and the virtual environment. Feel free to manage your own packages in any way you like
lets create a new directory (you can call it whatever you want)
i will call it
open the terminal and write