Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def lastyearsrevenue():
- sum2015 = 0.0
- mySQLconnection = mysql.connector.connect(host='sql9.freesqldatabase.com',database='sql9298674',user='sql9298674',password='KR5i4m6mya')
- sql_select_data = "select * from EMC_data" #to fetch all rows from the database
- data_cursor = mySQLconnection.cursor() #Creating a cursor to point to all entries in the database
- data_cursor.execute(sql_select_data) #returns a ResultSet object which contains all the rows
- data_records = data_cursor.fetchall()
- for row in range(data_cursor.rowcount):
- if "2015" in data_records[row][1]:
- if data_records[row][2].isdigit() and data_records[row][3].replace('$','').isdigit():
- #sum2015 += int(data_records[row][2])*float(data_records[row][3].replace('$',''))
- else:
- continue
- #print("The annual revenue for 2015 was: ",sum2015)
- connect_SQL_EMC_database()
- lastyearsrevenue()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement