Informatics Practices
The sales table of company database of MySQL stores the sales records of 100 salesmen. Write a program to load only those records in DataFrame which have made sales more than of 50000/-.
Python Pandas
8 Likes
Answer
import pandas as pd
import mysql.connector as sqltor
mycon = sqltor.connect(host = "localhost", user = "root", passwd = "mypass", database = "company")
df = pd.read_sql("SELECT * FROM sales WHERE Sales > 50000;", mycon)
print(df)Answered By
7 Likes
Related Questions
Write a program to get following data in two DataFrames :
df 1:
Roll no Name 1 ABC 2 DEF df2:
Roll no Marks 1 Marks 2 Marks 3 1 70 80 75 2 60 65 70 Store these DataFrames as two separate tables in the same database.
You have a database on MySQL namely school having three tables in it — Student, Subject, Teacher. Write a program to store these tables in three DataFrames.
The DataFrame SDF stores the sales records of 100 salesmen. Write a program to store this as a table in database namely "company" on MySQL.
Consider the SDF DataFrame storing the sales records of 100 salesmen. Write a program that stores only the first 25 rows of the DataFrame in a table on MySQL database.