Skip to content
Snippets Groups Projects
Commit 36828358 authored by francoisdillinger's avatar francoisdillinger
Browse files

Add water total to DB creation

parent 2ffad9cc
No related branches found
No related tags found
No related merge requests found
......@@ -228,6 +228,42 @@ def create_and_seed_db():
# Commit the changes
conn.commit()
###################################################################################################################################
###################################################################################################################################
############################################ Implement total water used in total table ############################################
# create a new table for total_cost_watts_water
# conn = psycopg2.connect(database="Team3DB", user="Team3", password="team3", host="138.26.48.83", port="5432")
# cur = conn.cursor()
cur.execute("""
DROP TABLE IF EXISTS total_cost_watts_water;
CREATE TABLE total_cost_watts_water (
month TEXT,
watts FLOAT,
cost FLOAT,
gallons_usage FLOAT
)
""")
conn.commit()
# Insert the monthly power, gallons, usage and cost values into the table
cur.execute("""
INSERT INTO total_cost_watts_water (month, watts, cost, gallons_usage)
VALUES ('January', %s, %s, %s),
('February', %s, %s, %s),
('March', %s, %s, %s)
""", (monthly_temp_watts_JAN+monthly_power2_JAN+monthly_power1_JAN, monthly_temp_ct_JAN+monthly_cost2_JAN+monthly_cost1_JAN, monthly_water_usg_JAN,
monthly_temp_watts_FEB+monthly_power2_FEB+monthly_power1_FEB, monthly_temp_ct_FEB+monthly_cost2_FEB+monthly_cost1_FEB, monthly_water_usg_FEB,
monthly_temp_watts_MAR+monthly_power2_MAR+monthly_power1_MAR, monthly_temp_ct_MAR+monthly_cost2_MAR+monthly_cost1_MAR, monthly_water_usg_MAR))
# Commit the changes
conn.commit()
######################################################################################################################################
######################################################################################################################################
######################################################################################################################################
# Close communication with the database
cur.close()
conn.close()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment