Commit 9c4230da authored by Matthias's avatar Matthias

change json transformation

parent 35b0a052
Pipeline #22328 failed with stages
in 35 seconds
......@@ -16,6 +16,7 @@
import os
import traceback
import mysql
import json
import mysql.connector as mariadb
from flask import request
from flask_restful import Resource, current_app
......@@ -26,7 +27,8 @@ from flasgger import swag_from
class MediaUrlUpdateService(Resource):
@swag_from('MediaUrlUpdateService.yml')
def post(self):
current_app.logger.debug('csv received: ' + str(request.get_json(force=True)))
json_str = request.get_data().decode()
current_app.logger.debug('csv received: ' + json_str)
try:
records_to_update = self._parse_csv_from_body()
self.db_cursor = self._connect_to_database()
......@@ -42,8 +44,8 @@ class MediaUrlUpdateService(Resource):
def _parse_csv_from_body(self):
# get parameters of request-body
csv_json = request.get_json(force=True)
return csv_json
json_str = request.get_data().decode()
return json_str
def _connect_to_database(self):
password = os.environ["mediaserver"].split(':')[1].split('@tcp(')[0]
......@@ -71,6 +73,7 @@ class MediaUrlUpdateService(Resource):
return self.db_cursor
def _update_records_in_database(self, records_to_update):
records_to_update_json = json.load(records_to_update)
for record in records_to_update:
try:
sql_stmt = 'UPDATE entities ' +\
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment