Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
IoTSmartMeter
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
kristian.tan
IoTSmartMeter
Commits
117ddad6
Commit
117ddad6
authored
Nov 13, 2019
by
Kristian Tan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Put DailyUsage in app.py
parent
fae0e213
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
2 deletions
+11
-2
app.py
app.py
+11
-2
No files found.
app.py
View file @
117ddad6
...
...
@@ -3,7 +3,7 @@ import RPi.GPIO as GPIO
from
flask_sqlalchemy
import
SQLAlchemy
from
sqlalchemy
import
create_engine
import
os
from
daily_usage
import
DailyUsage
#
from daily_usage import DailyUsage
app
=
Flask
(
__name__
)
os
.
environ
[
'SQLALCHEMY_DATABASE_URI'
]
=
'sqlite:///energyUsage'
...
...
@@ -15,11 +15,20 @@ GPIO.setwarnings(False)
db
=
SQLAlchemy
(
app
)
db
.
create_all
()
engine
=
create_engine
(
os
.
environ
[
'SQLALCHEMY_DATABASE_URI'
])
class
DailyUsage
(
db
.
Model
):
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
,
autoincrement
=
True
)
date
=
db
.
Column
(
db
.
String
(
80
),
unique
=
True
,
nullable
=
False
)
hours
=
db
.
Column
(
db
.
Integer
(
120
),
unique
=
False
)
def
__repr__
(
self
):
return
'<DailyUsage
%
r>'
%
self
.
id
test
=
DailyUsage
(
"12/11/2019"
,
5
)
db
.
session
.
add
(
test
)
db
.
session
.
commit
()
print
(
DailyUsage
.
query
.
all
())
# Create dictionary to store pin info
pins
=
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment