Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
CS 499
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hamid Choucha
CS 499
Commits
36828358
Commit
36828358
authored
2 years ago
by
francoisdillinger
Browse files
Options
Downloads
Patches
Plain Diff
Add water total to DB creation
parent
2ffad9cc
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
backend/database/CS_499_create_db.py
+36
-0
36 additions, 0 deletions
backend/database/CS_499_create_db.py
with
36 additions
and
0 deletions
backend/database/CS_499_create_db.py
+
36
−
0
View file @
36828358
...
...
@@ -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
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment