Sign in

Cloud Platform Engineer | IITR Alumnus

Consider you are working on a python application that needs to communicate with a Postgres database and you want to run SQL queries from the python application itself.

If you are working with a web application, using an object-relational mapper (ORM) would be the right and efficient way to go. But, working this way would also work if you don’t mind writing SQL queries or if you have only simple queries to run and don’t really need an ORM. Here’s how you can easily do it.

First, we’ll need to install Psycopg2:

pip install psycopg2-binary

Here are the steps:

  • Import…

Sometimes, when your project is too large to handle everything in one AWS account or when you maintain multiple environments in different AWS accounts and you need the data to flow between accounts, it becomes a headache to do all that with reconfiguring the IAM roles and S3 bucket policies to move/copy objects from one bucket to another in different accounts and still facing AccessDenied errors.

One such scenario is when you try to copy objects between s3 buckets across multiple AWS accounts.

I have divided this blog into 2 sections, one where you are using default S3 encryption to…

When it comes to backend development in Python, Django is one of the best frameworks you can find. It enables you to do fast development because of the number of features it has and its built-in ORM. Moreover, you can add new functionalities with the help of a wide variety of libraries specifically designed for Django. Here, we are going to discuss some of the important and popular ones.

Django Rest Framework (djangorestframework)
Django Rest Framework or DRF is inarguably the most popular plugin if you want to build APIs on top of your Django models. …

Suppose you are working with a significantly long runtime and contains multiple for loops. I am sure you must have added all the necessary logging to know the status of your running code.

While this is an absolutely good way to work on this type of use-cases, you can add a little beauty to your logs and give a treat to your eyes.

Here’s how you can add a progress bar to for loops in python.

First, you need to install a library called tqdm.

pip install tqdm

Add this to your iterators like this:

from tqdm import tqdmfor…

Implementing linked lists and binary trees using pointers in languages such as C++ might sound familiar to you, but what if you don’t want to use those languages? If you haven’t seen or done it before, data structures such as linked lists can easily be implemented using python classes. Here’s how you can do it.

Linked List:

You can define and create a linked list as shown below.

Binary Tree

You can define the tree data structure as a class and use it to create binary trees as shown below.

If you are proficient with lists in python…

  1. Creating Lists in one line:
lst = [x for x in range(0,10)]
>>> print(lst)
>>> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

2. Converting 2 lists to a dictionary:

list_1 = [“a”, “b”, “c”, “d”]
list_2 = [1, 2, 3, 4]
dict_from_lists = dict(zip(list_1, list_2))>>> print(dict_from_lists)
{‘a’: 1, ‘b’: 2, ‘c’: 3, ‘d’: 4}

Note: Both lists need to be of the same length

3. List to String:

lst = [“Convert”, “List”, “To”, “String”]
st = “ “.join(lst) #join and put " " between each element
>>> print(st)
'Convert List To String'

4. Split String:


For all those who want to work with remote Linux servers from their Windows computer, there are several ways to connect. For example, you might be using PuTTy or MobaXterm already. These tools are great and have some additional features as well.

What if you just want to use PowerShell for your ssh command. Yes, windows now have support for ssh in PowerShell. That’s not enough though, just like you use chmod 400 <your .pem file> for the permissions on Linux, you need to do a similar thing on Windows as well. So, I have noted down a list of PowerShell commands to do this.

Just update the path to your .pem key file and run these commands, you’ll be good to go. To ssh into your remote server, just run:

ssh -i "Path\to\your\ssh_key.pem" user@hostname

Hope, this helps.

Disclaimer: This article assumes that the reader is already familiar with django framework and can perform the basic functions of django and has some hands-on experience with AWS as well.

Django is a great framework to build web backends fast and we generally start the development by simply storing everything including static and media files on the development environment itself, be it your local machine or a development server on the cloud.

But, as your project grows bigger, these files can get costly to store on the server itself and it is also not recommended to do this, especially for…

The month of June was coming to an end and the hot winds gradually started to turn into the cold breeze. But still, there were no signs of rain in Gaurav’s village, Kalapi. He was expecting it to come soon and so were the others in the village. People started preparing their fields so that they can get a proper head start for their next crops when it rains. Crops weren’t the reason Gaurav was waiting for the monsoon, he was still a kid. In fact, he didn’t like the rains. For him, all it does is create mud and…

The trickling sound of whiskey poured into the glass was enough for them to forget their boring week. Ishan started the countdown from three and the others followed it to one and they started emptying their glasses simultaneously. They no longer bought those cheap spirits they used to buy in college but they are one of the main reasons which kept the trio together. It kinda helped strengthen the bond they had.

They finished one peg after another and one bottle after another. Brief cigarette sessions were also there in between the drinks, and with every drink, the silence was…

Devashish Patil

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