<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Prashant Dwivedi</title>
    <description>The latest articles on DEV Community by Prashant Dwivedi (@prashantdwivedi0801).</description>
    <link>https://dev.to/prashantdwivedi0801</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F746726%2F975a219a-0541-44a9-b887-a0f52fc7a7b6.png</url>
      <title>DEV Community: Prashant Dwivedi</title>
      <link>https://dev.to/prashantdwivedi0801</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/prashantdwivedi0801"/>
    <language>en</language>
    <item>
      <title>Simple Steps to Connect Flask App with MongoDB in an Ubuntu Machine</title>
      <dc:creator>Prashant Dwivedi</dc:creator>
      <pubDate>Mon, 20 Mar 2023 08:05:52 +0000</pubDate>
      <link>https://dev.to/prashantdwivedi0801/simple-steps-to-connect-flask-app-with-mongodb-in-an-ubuntu-machine-n09</link>
      <guid>https://dev.to/prashantdwivedi0801/simple-steps-to-connect-flask-app-with-mongodb-in-an-ubuntu-machine-n09</guid>
      <description>&lt;p&gt;To connect MongoDB with Flask in an Ubuntu machine, follow these steps:&lt;/p&gt;

&lt;p&gt;Install the pymongo package:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install pymongo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Install Flask-PyMongo package:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install Flask-PyMongo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In your Flask app, add the following code to create a connection to your MongoDB:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
from flask_pymongo import PyMongo

app = Flask(__name__)
app.config["MONGO_URI"] = "mongodb://localhost:27017/myDatabase"
mongo = PyMongo(app)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: Replace "myDatabase" with the name of your database.&lt;/p&gt;

&lt;p&gt;Use the mongo object to interact with the database. For example, to insert a document into a collection, use the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
myCollection = mongo.db.myCollectionName
myCollection.insert_one({"name": "John", "age": 30})


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: Replace "myCollectionName" with the name of your collection.&lt;/p&gt;

&lt;p&gt;That's it! Now you can use Flask and MongoDB together in your Ubuntu machine.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Quick SSH tour</title>
      <dc:creator>Prashant Dwivedi</dc:creator>
      <pubDate>Mon, 29 Aug 2022 19:20:23 +0000</pubDate>
      <link>https://dev.to/prashantdwivedi0801/quick-ssh-tour-1ho7</link>
      <guid>https://dev.to/prashantdwivedi0801/quick-ssh-tour-1ho7</guid>
      <description>&lt;p&gt;SSH which stands for &lt;strong&gt;&lt;code&gt;Secure Shell&lt;/code&gt;&lt;/strong&gt; is a protocol used for Secure Remote Login and File Transfer. In order to protect the confidentiality and integrity of the data transferred between the client and server, it employs powerful symmetric encryption and hashing methods.&lt;/p&gt;

&lt;p&gt;This article is focused to use SSH to make connections to remote machines on any cloud provider's end like AWS or Azure. For more information on how SSH works please look at &lt;a href="https://www.ssh.com/academy/ssh/protocol"&gt;SSH Protocol – Secure Remote Login and File Transfer&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here I will discuss the three basic way of connecting to any remote machine;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Using the Private Key / Password of the remote machine on every connection.&lt;/li&gt;
&lt;li&gt;Adding local machine's public key as authorized_keys on remote machine.&lt;/li&gt;
&lt;li&gt;Making a config file in local machine in &lt;code&gt;.ssh&lt;/code&gt; directory.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Whenever we make a new virtual machine on azure or an EC2 instance on AWS we have the option to down the SSH key or set a Username and Password for authentication.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Using the Private Key / Password of the remote machine on every connection.
&lt;/h3&gt;

&lt;p&gt;This is the simplest mode of establishing the connection with the remote machine; the command for this are as follows;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;a. Password based authentication&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh username@hostname 

Eg:

ssh prashant@1.1.1.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will be prompted to enter the password, once the password is entered, the connection is established with remote machine.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;b. SSH key based authentication&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Here, it is assumed that you have &lt;code&gt;.ssh&lt;/code&gt; folder in home directory. &lt;/li&gt;
&lt;li&gt;Download the SSH key for the remote machine from your respective cloud platform. For Azure, you are asked to download the one as soon as you create a New VM. Example Key File: &lt;code&gt;NewVM_key.pem&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Place this key in the .ssh folder&lt;/li&gt;
&lt;li&gt;Change the permission of the file with following command
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;chmod 400 &amp;lt;Key File Name&amp;gt;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Once this setup is done, one can easily authenticate and create an SSH session using the below command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh username@hostname -i &amp;lt;location of key file&amp;gt;

Eg: ssh azureuser@1.1.1.1 -i ~/.ssh/NewVM_key.pem

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As soon as the command is executed the connection is established, see image below&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--SESHNvFJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1jzauoad3jxp3tz3th2z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SESHNvFJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1jzauoad3jxp3tz3th2z.png" alt="Image description" width="880" height="665"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Adding local machine's public key as &lt;code&gt;authorized_keys&lt;/code&gt; on remote machine.
&lt;/h3&gt;

&lt;p&gt;Another good method of connecting to a remote machine is to save the local machine ( client's machine ) public key in &lt;code&gt;authorized_keys&lt;/code&gt; of server.&lt;/p&gt;

&lt;p&gt;Once this is done, next time we don't need to given the SSH key of server for connection ( as in method 1 ). The moment we ask for connection to the server, since server has our public it uses it for further authentication. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Steps to Save the public key in server:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Generate the public and private key pair on local machine ( client's machine ). Using the below command;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh-keygen -m PEM -t rsa -b 4096

Detailed: 
ssh-keygen \
    -m PEM \
    -t rsa \
    -b 4096 \
    -C "azureuser@myserver" \
    -f ~/.ssh/mykeys/myprivatekey \
    -N mypassphrase
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above command generates the two files &lt;code&gt;id_rsa&lt;/code&gt; and &lt;code&gt;id_rsa.pub&lt;/code&gt;, which are Private and Public keys of client's machine. Do not share your Private Key anywhere. &lt;br&gt;
Now add the &lt;code&gt;id_rsa.pub&lt;/code&gt; as &lt;code&gt;authorized_keys&lt;/code&gt; on server. Use below command,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh-copy-id -i ~/.ssh/id_rsa.pub username@hostname
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To add the Public manually, use the below command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cat ~/.ssh/id_rsa.pub | ssh user@remote-host 'cat &amp;gt;&amp;gt; ~/.ssh/authorized_keys'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once the above two steps are completed successfully, one can connect to remote server just by using the hostname and username without the need of Password or SSH key of server.&lt;/p&gt;

&lt;p&gt;For a diagrammatic representation of above process, I prepared an image for the same;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dMcV-lyQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1ravo4b7zm2dcl9q1bk9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dMcV-lyQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1ravo4b7zm2dcl9q1bk9.png" alt="Image description" width="880" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Making a config file in local machine in &lt;code&gt;.ssh&lt;/code&gt; directory.
&lt;/h3&gt;

&lt;p&gt;Third way of doing the same stuff and probably the most efficient and recommended way doing the things is to maintain a config file in &lt;code&gt;.ssh&lt;/code&gt; directory.&lt;/p&gt;

&lt;p&gt;This file contains the information of all the remote machines like host, hostname, username, password/shh key, etc. We can now ssh into the remote server only by using two word command, viz. &lt;code&gt;ssh&lt;/code&gt; and &lt;code&gt;host&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Procedure to create the config file&lt;/strong&gt;&lt;br&gt;
a. Go to &lt;code&gt;.ssh&lt;/code&gt; directory &lt;br&gt;
b. Now create the config file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;touch config
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--I8e5vzey--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8en2esofzqi0reh7meju.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--I8e5vzey--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8en2esofzqi0reh7meju.png" alt="Image description" width="548" height="305"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;c. Now open the file in you favorite editor, I will use vim here.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;vim config
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;d. Now enter all your remote machines' information in following manner&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Host NewVM
   HostName 20.129.27.139
   User prashant

Host OldVM
   HostName 21.36.12.596
   User azureuser
   IdentifyFile ~/.ssh/OldVM_key.pem
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For more information on &lt;code&gt;config&lt;/code&gt; file please look at this beautiful article &lt;a href="https://linuxize.com/post/using-the-ssh-config-file/"&gt;https://linuxize.com/post/using-the-ssh-config-file/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now as we have our config file set, we can ssh into any remote machine by just using the &lt;code&gt;host&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh NewVM

or

ssh OldVM
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That covers all third and the last method in this article. Hope you enjoyed reading and it added up to your knowledge.&lt;br&gt;
Please feel free to communicate in comments and let me know if any mistakes and suggestions.&lt;br&gt;
Thank You!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Cover Image Credits: &lt;a href="https://askme4tech.com/how-use-ssh-powershell"&gt;https://askme4tech.com/how-use-ssh-powershell&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>azure</category>
      <category>ssh</category>
      <category>aws</category>
    </item>
    <item>
      <title>Container VS Virtual Machines</title>
      <dc:creator>Prashant Dwivedi</dc:creator>
      <pubDate>Sun, 19 Jun 2022 18:24:50 +0000</pubDate>
      <link>https://dev.to/prashantdwivedi0801/container-vs-virtual-machines-214p</link>
      <guid>https://dev.to/prashantdwivedi0801/container-vs-virtual-machines-214p</guid>
      <description>&lt;p&gt;To understand the difference between the containers and virtual machines, we must first understand the concept of Virtualization.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is Virtualization?
&lt;/h3&gt;

&lt;p&gt;Virtualization is technology that lets you create useful IT services and projects using resources that are traditionally bound to hardware. It is a process in which the normal computer resources like CPU, RAM, Disk Space, etc. can be "virtualized" and can be used as multiple resources.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Both Containers and VMs are virtualization tools.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What are containers?
&lt;/h3&gt;

&lt;p&gt;If we discuss in short then, Containers are the technologies that allow you to package and isolate applications with their entire runtime environment—all of the files necessary to run.&lt;br&gt;
Before containers, in any development process the developers had to install the packages and tools required in development at there respective machines. Since different machines have different OS, it creates a great scope of error and bugs in all these installations.&lt;br&gt;
Containers solve these problems by creating an isolated environment with all these files and configurations and every developer can use this instance of software ( called as image ).&lt;/p&gt;

&lt;h3&gt;
  
  
  Difference between Container and VMs
&lt;/h3&gt;

&lt;p&gt;To understand the difference between these two we should look how OS is framed;&lt;/p&gt;

&lt;p&gt;Any Operating System has to layers above it's hardware; viz. OS Kernel Layer and Applications Layer. OS kernel interacts with hardware and applications are based on these kernel layers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gmrDUEcL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9s0mfg9aa7skhc8elm0d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gmrDUEcL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9s0mfg9aa7skhc8elm0d.png" alt="Image description" width="880" height="377"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The key difference between Containers and VMs is that a Container Environment virtualizes the Applications Layer whereas the VMs virtualize the Applications Layer + OS Kernel layer&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XZCduaa3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ghcagqdpe1j68gu3px7y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XZCduaa3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ghcagqdpe1j68gu3px7y.png" alt="Image description" width="880" height="418"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This means that VMs virtualize the complete operating system. Thus when we setup the VM then it did not use host's OS kernel, it boots up on it's own.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;KEY DIFFERENCES&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Containers are smaller in size as they just virtualize the applications layer while the VMs are big in size, generally few gigabytes. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Second is speed, we can run the containers pretty quickly as compared to VM, because they every time you start them, have to put the operating system kernel and the applications on top of it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The third difference is compatibility, so you can run a virtual machine image of any operating system on any other operating system host, but you can't do that with Containers.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That's it! This was the short and sweet look at the key differences between a container and a virtual machine.&lt;/p&gt;

&lt;p&gt;To learn more, I have pinned some great articles here!&lt;br&gt;
a. &lt;a href="https://www.atlassian.com/microservices/cloud-computing/containers-vs-vms"&gt;https://www.atlassian.com/microservices/cloud-computing/containers-vs-vms&lt;/a&gt;&lt;br&gt;
b. &lt;a href="https://www.redhat.com/en/topics/containers/containers-vs-vms"&gt;https://www.redhat.com/en/topics/containers/containers-vs-vms&lt;/a&gt;&lt;br&gt;
c. &lt;a href="https://www.redhat.com/en/topics/containers"&gt;https://www.redhat.com/en/topics/containers&lt;/a&gt;&lt;br&gt;
d. &lt;a href="https://www.redhat.com/en/topics/virtualization/what-is-a-virtual-machine"&gt;https://www.redhat.com/en/topics/virtualization/what-is-a-virtual-machine&lt;/a&gt;&lt;/p&gt;

</description>
      <category>docker</category>
      <category>containers</category>
      <category>virutalmachine</category>
      <category>vm</category>
    </item>
    <item>
      <title>How to use Redis without installing it in Windows/Linux</title>
      <dc:creator>Prashant Dwivedi</dc:creator>
      <pubDate>Mon, 13 Jun 2022 18:31:43 +0000</pubDate>
      <link>https://dev.to/prashantdwivedi0801/how-to-use-redis-without-installing-it-in-windowslinux-26h</link>
      <guid>https://dev.to/prashantdwivedi0801/how-to-use-redis-without-installing-it-in-windowslinux-26h</guid>
      <description>&lt;p&gt;Very often we feel the need of key-value pair database for our projects. However, using our main database for this purpose can be really tedious and an unnecessary task.&lt;/p&gt;

&lt;p&gt;During such times the only solution that comes to our mind is &lt;strong&gt;Redis!&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache, and message broker. One can make use of Redis whenever there is need of key-value pair database.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;: One good example of using the Redis is to store the status of some action, like if someone makes a request of password reset then we can allow the password reset only in next 5 min after the request is made. Now to maintain the status for this 5 minute we can make use of Redis. We can store some sort of key associated with this user which can auto expire in 5min.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using Redis
&lt;/h2&gt;

&lt;p&gt;Having said that, let's see how we can make use of Redis in our projects without any installations.&lt;/p&gt;

&lt;p&gt;One the major obstacles while working with Redis is that you need to install it in your machine and then launch the Redis server to use it. This can be done easily with Linux based system but unfortunately it can't be done that easily in Window's machine as Redis is not officially supported on windows ( as per my knowledge ) so you need to do some workaround like WSL, etc.&lt;/p&gt;

&lt;h3&gt;
  
  
  Redis Cloud
&lt;/h3&gt;

&lt;p&gt;Just head on to &lt;code&gt;https://app.redislabs.com/&lt;/code&gt; and make your account on redis labs page.&lt;/p&gt;

&lt;p&gt;It offers a free plan which includes &lt;strong&gt;30MB&lt;/strong&gt; of space ( which is enough for storing key-value pairs for small projects ) and 1 dedicated database&lt;/p&gt;

&lt;p&gt;Screenshot of Making the Database&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6HI45Rk7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p7e5aoxx2n4jdzajvhfu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6HI45Rk7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p7e5aoxx2n4jdzajvhfu.png" alt="Image description" width="880" height="432"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Upon successful creation of database we get to see following dashboard&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kCvxJ5RJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jlvo6lovq2csagvz2mbd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kCvxJ5RJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jlvo6lovq2csagvz2mbd.png" alt="Image description" width="880" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Just Click on the database and copy the following credentials&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Public endpoint
This is of the format: &lt;code&gt;host:port&lt;/code&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GS84PTCo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5rdrkpf6rjno69popq0x.png" alt="Image description" width="880" height="433"&gt;
&lt;/li&gt;
&lt;li&gt;Default user password
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9__SJekO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cycjvzibwacx5719l2ra.png" alt="Image description" width="880" height="438"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now since we have these credentials we can connect to our database and use Redis as usual. &lt;/p&gt;

&lt;p&gt;Below is the example with Python. I have saved the credentials in environment file. One can directly put the credentials below. Eg: In place of os.getenv("REDIS_HOST") directly put the host url.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;redis&lt;/span&gt;
&lt;span class="n"&gt;red&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;redis&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Redis&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;host&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;getenv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"REDIS_HOST"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="n"&gt;port&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;getenv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"REDIS_PORT"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; 
    &lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;getenv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"REDIS_PASSWORD"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;red&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"key"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"value"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;red&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"key"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>redis</category>
      <category>redisla</category>
    </item>
    <item>
      <title>Understanding the Git Upstream Tracking</title>
      <dc:creator>Prashant Dwivedi</dc:creator>
      <pubDate>Mon, 13 Jun 2022 14:20:12 +0000</pubDate>
      <link>https://dev.to/prashantdwivedi0801/understanding-the-git-upstream-tracking-56d0</link>
      <guid>https://dev.to/prashantdwivedi0801/understanding-the-git-upstream-tracking-56d0</guid>
      <description>&lt;p&gt;When using the git for version control and GitHub as the remote repo then we often get an error when we run the following command;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;git pull&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;git push&lt;/strong&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OdShzsZN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/riavnuvr0ss06bb0ckhu.png" alt="Image description" width="880" height="550"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now the question is what is this upstream?&lt;/p&gt;

&lt;h3&gt;
  
  
  What is Upstream Tracking?
&lt;/h3&gt;

&lt;p&gt;To understand this let us say you have one remote repository and one local repository. The local repository has the remote connection with remote repository on GitHub. Now, lets say we made a local branch named &lt;strong&gt;branch_1&lt;/strong&gt; and we want to push this new branch to remote repository for this we simply pushed it to remote repo using the command&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;git push origin branch_1&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now our remote repository has the branch named &lt;strong&gt;branch_1&lt;/strong&gt; Till this moment of time nothing feels bad, unless we again make some changes in our local &lt;strong&gt;branch_1&lt;/strong&gt; and push it to remote by simply writing the following command&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;git push&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is the moment we get the above error saying that &lt;strong&gt;&lt;em&gt;"there is no tracking information for current branch"&lt;/em&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This simply means that there is no "&lt;strong&gt;Upstream Tracking Branch&lt;/strong&gt;" for your current local branch.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is an Upstream Branch?
&lt;/h3&gt;

&lt;p&gt;Upstream branches are the branch that used to track the remote branches by your local branch. To make it simple, if you current local branch named &lt;strong&gt;branch_1&lt;/strong&gt; had the upstream tracking then we will have one branch named &lt;strong&gt;remotes/origin/branch_1&lt;/strong&gt; or simply &lt;strong&gt;origin/branch_1&lt;/strong&gt;. Whereas, if the tracking is not set then we don't get any such branch.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: Don't confuse the &lt;strong&gt;remote/branch_1&lt;/strong&gt; as the remote repository branch, this is not the remote repo branch but just a latest copy of that remote branch.&lt;/p&gt;

&lt;p&gt;These upstream branches are used to keep up with latest changes. &lt;/p&gt;

&lt;h3&gt;
  
  
  Why we got those errors?
&lt;/h3&gt;

&lt;p&gt;Now that we have some understanding of upstream tracking, we can understand the cause of those errors.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;git push&lt;/strong&gt;: When we simply do git push, then since our current branch is not tracking any remote branch, it does not know to which branch to push these changes in remote and thus we get that error.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;git pull&lt;/strong&gt;: When we do git pull, then since our current branch is not tracking any remote branch, it does not know form which branch to pull the latest changes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once we have our upstream tracking set, we can run simple git pull and git push commands without any error because now the current local branch knows which branch it is associated with in the remote repository. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to check the upstream tracking status for any branch?&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;We can check the upstream tracking status for all the branches using the following command&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;git branch -vv&lt;/strong&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Xipi8wWw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7xzso8zhubjj8l3wmu3g.png" alt="Image description" width="674" height="122"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here we can see that&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;branch named "branch" has no upstream tracking, but&lt;/li&gt;
&lt;li&gt;master branch is having the upstream tracking branch origin/master&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How to set up the upstream tracking for any branch?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We can se the upstream tracking for any branch with following simple method&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;When we are pushing our branch to remote repository just use "-u"&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   git push -u origin &amp;lt;branch_name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>git</category>
      <category>github</category>
    </item>
  </channel>
</rss>
