[Tutorial] Here is how to work with the new async SQLAlchemy ORM

I think the whole python web development community has been waiting for this change for a while and I personally was extremely happy to hear about the long awaited async orm functionality in SQLAlchemy when the beta version was released on February 3rd in the start of this year and official release v1.4.0 on 15th of March.

Before we dive into SQLAlchemy’s async orm, there has been a bunch of async orm tools that are worth mentioning: Tortoise ORM, Pony ORM, PeeWee and Gino. …


Simplify your web development with docker and docker-compose

Intro

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

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…


Simplify your python web-development with FastAPI and docker

Intro

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.

Docker

According to the docker documentation

Docker…


Which package manager to use in 2020?

Intro

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.

The Pip

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…


Intro

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

Lets Start

Install the required package databases

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 install asyncpg…


The easiest way for parsing request payload and query parameters

Intro

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. flask-restful, flask-restplus , 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.

Marshmallow

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.

Intro

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

Install

pip install covid

Requirements

python >= 3.6

Usage

from covid…


Tutorial for Mkdocs with material theme and hosting on github pages

Intro

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.

The current documentation

The previous years I have always used sphinx to create code documentation, and you usually end up with documentation like the…


What the hell is Sanic web framework anyway?

Intro

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.

The Facts

At the time this article was written, Sanic on github has around 13.5k stars, 226 contributors and is used by 2.7k

Ahmed Nafies

Software Developer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store