Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Temperaturverteilung
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
s39174
Temperaturverteilung
Commits
3b69b840
Commit
3b69b840
authored
3 years ago
by
Clemens Berteld
Browse files
Options
Downloads
Patches
Plain Diff
Initial API commit
parent
6859a799
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dataacquisition/ExportToDatabase.py
+2
-3
2 additions, 3 deletions
dataacquisition/ExportToDatabase.py
dataacquisition/api.py
+23
-0
23 additions, 0 deletions
dataacquisition/api.py
with
25 additions
and
3 deletions
dataacquisition/ExportToDatabase.py
+
2
−
3
View file @
3b69b840
...
...
@@ -67,6 +67,8 @@ def insert_data(stationList):
with
connection
.
cursor
()
as
cursor
:
if
len
(
stationList
)
>
0
:
cursor
.
execute
(
"
DELETE FROM stations;
"
)
df_columns
=
list
(
stationList
)
# create (col1,col2,...)
...
...
@@ -89,6 +91,3 @@ def insert_data(stationList):
def
export
(
stationList
):
check_for_db_existence
(
stationList
)
insert_data
(
stationList
)
# return stationList
This diff is collapsed.
Click to expand it.
dataacquisition/api.py
0 → 100644
+
23
−
0
View file @
3b69b840
import
json
import
psycopg2
from
flask
import
Flask
,
jsonify
from
psycopg2
import
sql
app
=
Flask
(
__name__
)
app
.
config
[
'
ENV
'
]
=
"
development
"
app
.
config
[
'
DEBUG
'
]
=
True
# Testing: Exceptions are propagated rather than handled by the the app’s error handlers. Extensions may also change their behavior to facilitate easier testing. You should enable this in your own tests.
app
.
config
[
'
TESTING
'
]
=
False
@app.route
(
'
/
'
)
def
index
():
with
psycopg2
.
connect
(
database
=
'
temperatures_berteld_morstein
'
,
user
=
'
postgres
'
,
password
=
'
postgres
'
,
host
=
'
localhost
'
,
port
=
5432
)
as
connection
:
with
connection
.
cursor
()
as
cursor
:
# query = sql.SQL("""CREATE TABLE stations ({});""".format(columns_clean))
pass
return
jsonify
({
'
läuft
'
:
'
jo
'
})
app
.
run
(
host
=
'
127.0.0.1
'
,
port
=
42000
)
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