Exemplo n.º 1
0
def insert_or_update_resource(RE_id: int, ST_id: int, MR_id: int,
                              resource_data: resource.Resource):
    resource_data = str(json.dumps(resource_data.dict()))
    select_Query = "select from create_or_update_resources(%s,%s,%s,%s);"
    data = (
        RE_id,
        ST_id,
        MR_id,
        resource_data,
    )
    res = Connect_TO_DB(select_Query, data)
    return {}
Exemplo n.º 2
0
def insert_or_update_resource(RE_id: int, ST_id: int, MR_id: int,
                              resource_data: resource.Resource):
    con = psycopg2.connect(dbname=DB_name,
                           user=DB_user,
                           password=DB_pass,
                           host=DB_Host)
    cur = con.cursor()
    resource_data = str(json.dumps(resource_data.dict()))

    cur.execute(
        'show search_path; set search_path to casa_della_energia ;select from create_or_update_resources(%s,%s,%s,%s);',
        (RE_id, ST_id, MR_id, resource_data))

    res = cur.fetchall()
    con.commit()
    cur.close()
    print(res)
    if con is not None:
        con.close()
    return {}