Skip to content
Snippets Groups Projects
Commit 3b69b840 authored by Clemens Berteld's avatar Clemens Berteld
Browse files

Initial API commit

parent 6859a799
No related branches found
No related tags found
No related merge requests found
...@@ -67,6 +67,8 @@ def insert_data(stationList): ...@@ -67,6 +67,8 @@ def insert_data(stationList):
with connection.cursor() as cursor: with connection.cursor() as cursor:
if len(stationList) > 0: if len(stationList) > 0:
cursor.execute("DELETE FROM stations;")
df_columns = list(stationList) df_columns = list(stationList)
# create (col1,col2,...) # create (col1,col2,...)
...@@ -89,6 +91,3 @@ def insert_data(stationList): ...@@ -89,6 +91,3 @@ def insert_data(stationList):
def export(stationList): def export(stationList):
check_for_db_existence(stationList) check_for_db_existence(stationList)
insert_data(stationList) insert_data(stationList)
# return stationList
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)
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