def insert_or_update_station(ST_id: int, station_data: station.Station): select_Query = "select from create_or_update_station(%s,%s);" station_data = str(json.dumps(station_data.dict())) data = ( ST_id, station_data, ) res = Connect_TO_DB(select_Query, data) return {}
def insert_or_update_station(ST_id: int, station_data: station.Station): con = psycopg2.connect(dbname=DB_name, user=DB_user, password=DB_pass, host=DB_Host) cur = con.cursor() station_data = str(json.dumps(station_data.dict())) print(station_data) cur.execute( 'show search_path; set search_path to casa_della_energia ;select from create_or_update_station(%s,%s);', (ST_id, station_data)) res = cur.fetchall() con.commit() cur.close() print(res) if con is not None: con.close() return {}