diff --git a/dataacquisition/ExportToDatabase.py b/dataacquisition/ExportToDatabase.py index 544ecff769f95736f17cbe8b0011235bfca39be9..e451cde8f5fc994658454c70458ce47ba3a0bd73 100644 --- a/dataacquisition/ExportToDatabase.py +++ b/dataacquisition/ExportToDatabase.py @@ -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 - diff --git a/dataacquisition/api.py b/dataacquisition/api.py new file mode 100644 index 0000000000000000000000000000000000000000..c72dc1d19784aab6bd101b370853b174f4716fc3 --- /dev/null +++ b/dataacquisition/api.py @@ -0,0 +1,23 @@ +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)