mysql client documentation-windows

~Sandhiya

What is mysqlclient?

The client package also comes with utilities that allow you to easily backup/restore data and administer the server.

Install mysqlclient for windows

Go to the link: https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysqlclient

Download the file which version supported your system

Download the file: mysqlclient-1.4.4-cp37-cp37m-win32.whl

open the terminal: type pip install mysqlclient-1.4.4-cp37-cp37m-win32.whl

 

Documentation on debugging issue for creating database

While running the crawler code to extract data about the categories(Beauty -> Tools and Accessories  products) in amazon.in,  I had come across the following error. I will be showing what I had done to rectify the error.

runfile(‘C:/Users/Dell/Documents/Quilt/quilt-beauty/quilt-beauty/amazon_beauty_skin_crawler.py’, wdir=’C:/Users/Dell/Documents/Quilt/quilt-beauty/quilt-beauty’)

Error tokenizing data. C error: Expected 7 fields in line 68, saw 8

If you look at the database, the database will be empty.

To look at the database, open the ‘db.sqlite3’ file using DB Browser (SQLite) application.

To rectify the error, we need to open the .csv in a normal word editor e.g. notepad++

You will be able to see the ‘ ” ’ double quotes at the beginning and at the end.

Remove the double quotes and save the text file.

NOTE: If there are already data in the database, to remove the data from the database do the following.

Open the db.sqlite3 file using DB Browser (SQLite) application.

Go to ‘Execute SQL’ tab

Type the following command

delete from file_name

delete from beauty_skin_categories

The above command will delete the data that was present in the database.

To execute the command run the command, click the run button.

After running the command click ‘Write Changes’

Then open Spyder and run the code. This time it should work.

The database for the beauty_skin_categories table will be created.

 

How to use Git in Eclipse(Cloning a respiratory)

–  Prabaharan

1.Open your Gitlab

To copy the URL that you want to clone in your local respiratory.

Go to: Project -> Details

Select “Clone” and under “Clone with HTTPS”press on the “copy URL to clipboard”

 

2. Open Eclipse

Go to:  Windows -> Preference -> Open Preferences -> Other

‘Open Properties’ window will pop up

Select ‘Git folder’ in that as shown below and press ‘Open’

‘Source Git Repository’ window will pop up

Paste the copied URL in the URL text box under the ‘Location’ tab

Also provide the ‘User ‘ and ‘Password’ for gitlab.com under the ‘Authentication ‘ tab.

Press Next

‘Branch Selection’ window will pop up

Select the respective branch that you need

Press Next

The directory where the repository to be cloned will be shown.

After that select ‘Finish’

Select the folder which you want to import.

Right click on the folder and select ‘Import Projects’ from the dropdown.

This will lead to location of your local directory.

Click ‘Finish’ to complete.

 

 

 

Sample WebScraping

########### Source code for webscraping ############

from selenium import webdriver
from bs4 import BeautifulSoup
import pandas as pd
driver = webdriver.Chrome("/home/ranjith/Documents/Software/Chrome/chromedriver_linux64/chromedriver")
products=[] #List to store name of the product
prices=[] #List to store price of the product
driver.get("https://www.flipkart.com/laptops/~buyback-guarantee-on-laptops-/pr?sid=6bo%2Cb5g&uniq")
content = driver.page_source
soup = BeautifulSoup(content)
for a in soup.findAll('a', attrs={'class':'_31qSD5'}):
    name=a.find('div', attrs={'class':'_3wU53n'})
    price=a.find('div', attrs={'class':'_1vC4OE _2rQ-NK'})
    rating=a.find('div', attrs={'class':'hGSR34 _2beYZw'})
    try:
        products.append(name.text)
    except:
        products.append("-----")
    try:
        prices.append(price.text)
    except:
        prices.append('-----')
df = pd.DataFrame({'Product Name':products,'Price':prices}) 
print(df)

######## OUTPUT ###########

                                        Product Name    Price
0  Apple MacBook Air Core i5 5th Gen - (8 GB/128 ...  ₹67,990
1  HP 15 Core i3 6th Gen - (4 GB/1 TB HDD/Windows...  ₹28,997
2  Apple MacBook Air Core i5 5th Gen - (8 GB/256 ...  ₹92,500
3  Lenovo Core i5 7th Gen - (8 GB/1 TB HDD/DOS/2 ...  ₹52,990
4  Lenovo Core i3 6th Gen - (4 GB/1 TB HDD/Window...  ₹30,550
5  Lenovo Ideapad Core i3 6th Gen - (4 GB/1 TB HD...  ₹32,990
6  Lenovo Core i5 7th Gen - (8 GB/2 TB HDD/Window...  ₹75,500

GCD and LCM using Sympy in Python

##########Source code for finding GCD and LCM using Sympy in python#########
from sympy import *
x = Symbol('x')
expression1, expression2 = x**2 + 4*x - 12, x**2 - 5*x + 6
def findGCD(expression1, expression2):
    print("########### Find GCD ############")
    factorsExpr1, factorsExpr2 = factor(expression1), factor(expression2)
    print("factorsExpr1 : ", factorsExpr1)
    print("factorsExpr2 : ", factorsExpr2)
    GCD = gcd(expression1, expression2)
    print("GCD : ", GCD)
    return GCD
def findLCM(expression1, expression2, GCD):
    print("########### Find LCM ############")
    factorsExpr1, factorsExpr2 = factor(expression1), factor(expression2)
    LCM = factor(lcm(expression1, expression2))
    print("LCM of Expr1 and Expr2 : ", LCM)
    print("f(x)*g(x) = ", factor(expression1*expression2))
    print("(f(x)*g(x))/GCD = {0}/{1}".format(factor(expression1*expression2),GCD))
    LCM = simplify((factorsExpr1*factorsExpr2)/GCD)
    print('Finding LCM using (f(x)*g(x))/GCD" : ', LCM)
    return LCM
GCD = findGCD(expression1, expression2)
LCM = findLCM(expression1, expression2, GCD))
######## OUTPUT #############
########### Find GCD ############
factorsExpr1 :  (x - 2)*(x + 6)
factorsExpr2 :  (x - 3)*(x - 2)
GCD :  x - 2
########### Find LCM ############
LCM of Expr1 and Expr2 :  (x - 3)*(x - 2)*(x + 6)
f(x)*g(x) =  (x - 3)*(x - 2)**2*(x + 6)
(f(x)*g(x))/GCD = (x - 3)*(x - 2)**2*(x + 6)/x - 2
Finding LCM using (f(x)*g(x))/GCD" :  (x - 3)*(x - 2)*(x + 6)

Installing R on Ubuntu 64x

edit /etc/apt/sources.list
paste deb https://cloud.r-project.org/bin/linux/ubuntu trusty-cran35/
sudo apt-get update
sudo apt-get install r-base (first uninstall if already older version R base is installed using sudo apt-get remove r-base)
sudo apt-get install r-base-dev
sudo apt-get install r-base-dev
Y or I : install the package maintainer's version

Triangle inequality rule

We were working with area and construction of triangles with the 6th graders in Isaiambalam school initially children started to construct a triangle with compass on their note books. Then to make things a little interesting children were asked how they would do it in scratch.

They initially started to draw three sides and found out that is was only possible to do, when the user gave three sides and two angles. Then one of then came up with using the arc function. He first drew the base, then two circles with the radius as the other two sides. Now he got the intersection point,  by this time I was confused as of how to get the third point in scratch. The solution was tracing the distance from one circles center to the other circles circumference and when they meet to set a variable to the x and y location and that did it.

Link to scratch code : link to program

More work done by children at Isaiambalam School :

Shapes and angles with 5th grade

 

 

Welcome Anupama

Anupama Jagadeesh deeply cares about self-exploration. She has 18 years of experience in web based applications for various corporates in the US and and has just moved from Seattle. She was a senior development lead delivering products primarily on Java platforms. She is very interested in alternative education and she trained herself in Montessori and has home schooled her two children.

She is supporting us in making the school database software automated version in the afternoons after 2pm. It is really helpful for us to have a senior and experienced person to work with.

Scratch course in Thamarai learning Centre

In Thamarai Learning Centre  STEM land team offered a basic scratch course in the evening for 5 days from 5.30 PM  to 7 PM. The facilitator in that centre didn’t know about scratch so they also joined  the course. There were about 15 children and 4 facilitators.

Day 1:
First day we introduced the different blocks and its function in scratch. Children started to explore and were excited in exploring the different options in Scratch. We have asked the children to create 10 question and answers. Then we introduced how to have a conversation between two people. Initially we showed them how to make a conversation with the 10 question. Slowly children started doing it on their own. They learnt to use ‘sensing’ and ‘=’ operators to ask 10 questions. When the wrong answer is typed, the same question should be asked again until the user gives the correct answer.

Day 2&3:
We introduced the pen function and motion function. Using these functions we showed them how to draw with and object and also to move a objects. Once when they were able to finish we had asked them to draw a triangle. They didn’t want to give up and after 15 minutes they figured it out. Then we asked them to draw a square, pentagon,hexagon, heptagon, octagon. Then they were able to draw different types of mandalas using ‘rotate’ block.

Day 4&5:
We had introduced children hoe to build a maze game. We showed how to move a object when a key is pressed. Children worked in pairs with each other to create a maze path in the backdrop image. They were able to use sensing function and also become familiar with motion function.

Everyday we asked children to sit in a circle at end of the session for 10 minutes. We asked them to share one thing that they learnt in the session. All the children share something that they learnt.

Most of the children loved and enjoyed building their own game. This created confidence in children that they can make many things using scratch.

To learn Scratch     Click here

Raspberry pi course

In STEM land a person from Auroville came to the iSMART class to conduct a course about raspberry pi course. Initially I dont know how to use raspberry pi. I was curious to learn raspberry pi. I also learnt the differences and advantages between Arduino and Raspberry pi. I learnt the different pin functions and the number of pins on a raspberry pi board. Day 1&2 was fully theory session which was boring.

In order to make it interesting I started ask many question to the teacher and the session was engaged by the participants. What really was interesting in the course was that the Arduino can’t drive a relay but with a raspberry pie we can drive a relay. One the teacher told that a relay can be driven by rapberry, he had a relay module but he couldn’t drive it. I took as a challenge and struggled for two days and I figured it to drive a relay. We made a small circuit with 2 LED where when the relay is on one of that LED will turn on and when the relay is off the other LED will turn on.

      

After this the teacher was also very happy and he also learnt something from us. Then the next challenge was that to send and to receive inputs from a raspberry pi to a web page.The teacher had asked who knows web page development.

             

Since I learnt Django web framework in STEM land, I was able to connect What I knew with what I lean now.  So I had asked him to show an example how to pass inputs from raspberry to a web page. Then finally in the last class we were able to complete all the task that we planed to accomplish in the course. Now I have some knowledge about raspberry pi and also I can build something with it.

To learnt about raspberry pi visit this link      Click here