<?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: Ashish Nair</title>
    <description>The latest articles on DEV Community by Ashish Nair (@ashishnair1211).</description>
    <link>https://dev.to/ashishnair1211</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%2F487062%2Fd7c61e93-5d79-4006-a536-5d03236f8502.png</url>
      <title>DEV Community: Ashish Nair</title>
      <link>https://dev.to/ashishnair1211</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ashishnair1211"/>
    <language>en</language>
    <item>
      <title>Send Emails with Python : sending emails with just 6 lines of code</title>
      <dc:creator>Ashish Nair</dc:creator>
      <pubDate>Tue, 13 Oct 2020 17:45:49 +0000</pubDate>
      <link>https://dev.to/ashishnair1211/email-with-python-sending-emails-with-just-6-lines-of-code-3dm0</link>
      <guid>https://dev.to/ashishnair1211/email-with-python-sending-emails-with-just-6-lines-of-code-3dm0</guid>
      <description>&lt;p&gt;If you are looking for a way to send emails with python, look no more.&lt;/p&gt;

&lt;p&gt;Lets jump into it,&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Emails with Python&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;We'll use the Smtp module a built-in python library to send emails,&lt;/p&gt;

&lt;p&gt;So lets start with importing it first,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import smtplib
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now that this is out of the way lets look at the code,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;message = f'Subject : Upcoming Due Date Alert : {left} Days \nDear User, \n\n\nThis message is regarding the upcoming due date for {Details} on {Date}. \n\nRegards,\nPython ;)'
        server = smtplib.SMTP(host = 'smtp.gmail.com',port=587)
        server.ehlo()
        server.starttls()
        server.login(sender_mail,sender_password)
        server.sendmail(sender_mail,receiver_mail,alert_message)
        server.quit()
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The server variable defines the email host which is 'gmail.com' and the port that we will be using to send the email. The &lt;code&gt;server.ehlo()&lt;/code&gt; function is a hostname argument for the email client and the &lt;code&gt;server.starttls()&lt;/code&gt; is to encrypt the email.&lt;/p&gt;

&lt;p&gt;That is it, that's all it takes to send emails using python. Making sending bulk emails easy, all thanks to python. You can pass a list of receiver emails to the &lt;code&gt;receiver_mail&lt;/code&gt; variable which would send the emails to multiple people.&lt;/p&gt;

&lt;p&gt;Go and try send some emails with Python.&lt;/p&gt;

</description>
      <category>python</category>
    </item>
    <item>
      <title>Sqlite 3 - Python Database</title>
      <dc:creator>Ashish Nair</dc:creator>
      <pubDate>Tue, 13 Oct 2020 16:33:21 +0000</pubDate>
      <link>https://dev.to/ashishnair1211/sqlite3-database-in-python-5cac</link>
      <guid>https://dev.to/ashishnair1211/sqlite3-database-in-python-5cac</guid>
      <description>&lt;p&gt;If you were using files to store the program data, here is a better way to store the data,&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;strong&gt;Using built-in Sqlite 3 database in Python.&lt;/strong&gt;
&lt;/h1&gt;

&lt;p&gt;So lets start with importing the the Sqlite 3 module in python,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import sqlite3
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Next, lets connect the database with &lt;strong&gt;sqlite&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;conn = sqlite3.connect('Client_data.db')
conn.execute('''CREATE TABLE Client_db
                (NAME            BLOB NOT NULL,
                PASSWORD         BLOB NOT NULL,
                EMAIL            VARCHAR(320) NOT NULL);''')
conn.commit()
conn.close()
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This creates a sqlite database 'Client_data.db', and creates a table named 'Client_db' with columns Name, password and email.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Adding values to the database&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Now that we have created a sqlite database and a table consisting of columns, we can add values to the table.&lt;/p&gt;

&lt;p&gt;We can do that like this,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cursor = conn.cursor()
params = (username,password,receiver_mail)
cursor.execute("INSERT INTO Client_db VALUES (?,?,?)",params)
conn.commit()
print('User Creation Successful')
conn.close()

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



&lt;p&gt;The '?' operator is used to pass the values of a variable, sort of like the 'f' string in Python.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Reading from the Sqlite 3 database&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;To read from the sqlite database there are two methods,&lt;/p&gt;

&lt;p&gt;&lt;code&gt;fetchone()&lt;/code&gt; : fetches the first row in the sqlite database that matches the passed in filters.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;fetchall()&lt;/code&gt; : fetches all the rows in the sqlite database that match with the filter.&lt;/p&gt;

&lt;p&gt;Take a look at the code,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;conn = sqlite3.connect('Client_data.db')
cur = conn.cursor()
cur.execute("SELECT * FROM Client_db WHERE NAME =:NAME",{'NAME':username})
if cur.fetchone()[1] == password:
     print('LogIn Successful')    
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This queries the row where the name matches the name passed in, and it fetches the password relating to that username using the &lt;code&gt;fetchone()&lt;/code&gt; method from the sqlite database, and matches the password with the one passed into the program and if the passwords match it prints out 'LogIn Successful'.&lt;/p&gt;

&lt;p&gt;You can find more on the Sqlite 3 Database in python &lt;a href="https://www.sqlitetutorial.net/sqlite-python/"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Peace !
&lt;/h2&gt;

</description>
      <category>sql</category>
      <category>python</category>
      <category>programming</category>
      <category>database</category>
    </item>
    <item>
      <title>Building A Reddit Bot Using Python &amp; Selenium</title>
      <dc:creator>Ashish Nair</dc:creator>
      <pubDate>Mon, 12 Oct 2020 14:55:54 +0000</pubDate>
      <link>https://dev.to/ashishnair1211/building-a-reddit-bot-using-python-selenium-19l5</link>
      <guid>https://dev.to/ashishnair1211/building-a-reddit-bot-using-python-selenium-19l5</guid>
      <description>&lt;h2&gt;
  
  
  "The Age of Automation will be the age of Do it Yourself"- Marshall McLuhan
&lt;/h2&gt;

&lt;p&gt;Have you ever tried sharing a post to your friend on Reddit using it's DM? If you have then you know how cumbersome the process of sharing the posts via DM is, I mean you got to first copy the link of the post that you would like to share and then open the inbox and paste the link you just copied and then FINALLY send it to your friend.&lt;/p&gt;

&lt;p&gt;So, One day during one of my expeditions on Reddit, was surfing through posts and I thought why not automate the post sharing on Reddit and that is exactly what I did.&lt;/p&gt;

&lt;p&gt;I used Selenium to do this using Python. What this does is it basically detects the new posts that you upvote, from the upvotes section and sends the latest post that you upvote to the person whose username you pass to the program in the beginning.&lt;/p&gt;

&lt;p&gt;I have provided the link to my code and my blog down below, do check them out.&lt;/p&gt;

&lt;p&gt;It would be great if you could provide feedbacks on my code. &lt;/p&gt;


&lt;div class="ltag__link"&gt;
  &lt;a href="https://medium.com/analytics-vidhya/building-a-reddit-bot-with-selenium-web-driver-87ece50c7d5" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vj_uw9Qw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/fit/c/96/96/1%2A1D8qs0Pbk2auRAkeF-dkjA.jpeg" alt="Ashish Nair"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://medium.com/analytics-vidhya/building-a-reddit-bot-with-selenium-web-driver-87ece50c7d5" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;Building A Reddit Bot with Selenium Web Driver | by Ashish Nair | Analytics Vidhya | Oct, 2020 | Medium&lt;/h2&gt;
      &lt;h3&gt;Ashish Nair ・ &lt;time&gt;Oct 10, 2020&lt;/time&gt; ・ 3 min read
      &lt;div class="ltag__link__servicename"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KBvj_QRD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/medium_icon-90d5232a5da2369849f285fa499c8005e750a788fdbf34f5844d5f2201aae736.svg" alt="Medium Logo"&gt;
        Medium
      &lt;/div&gt;
    &lt;/h3&gt;
&lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;



&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vJ70wriM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/sectrumsempra"&gt;
        sectrumsempra
      &lt;/a&gt; / &lt;a href="https://github.com/sectrumsempra/Reddit_Bot.py"&gt;
        Reddit_Bot.py
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
Reddit_Bot.py&lt;/h1&gt;
&lt;p&gt;Sharing files on Reddit just got a whole lot simpler.&lt;/p&gt;
&lt;p&gt;This bot automates the process of copying and sharing the posts on Reddit's Direct messaging to your friends.
This bots logs in to your Reddit account and sends the link to the post you most recently upvoted and keeps refreshing to get the new upvoted posts in Real Time.
The bot was built using Selenium.&lt;/p&gt;
&lt;/div&gt;



&lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/sectrumsempra/Reddit_Bot.py"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;br&gt;


</description>
      <category>python</category>
      <category>programming</category>
      <category>automation</category>
      <category>bot</category>
    </item>
  </channel>
</rss>
