def manageSource(cursor, ref_citation, ref_link):
    """
    Testing whether one source and its associated link exist in the database, if not insert it in the database
    
    Parameters
    -----------
    cursor: psycopg2 cursor
        cursor for the current operations in the database
    ref_citation: str
        complete text describing the reference
    ref_link
        URL link to the reference ressources
    
    Returns
    ------------
    return the cd_ref to the reference
    """
    # Does the source exist
    if ref_link == ' ':
        ref_link = None
    SQL = "SELECT count(*) FROM refer WHERE citation = %s"
    cursor.execute(SQL, [ref_citation])
    nb, = cursor.fetchone()
    cit_exists = bool(nb)
    if cit_exists:
        SQL = "SELECT cd_ref FROM refer WHERE citation = %s"
        cursor.execute(SQL, [ref_citation])
        cdRef, = cursor.fetchone()
    else:
        # insertion of the source if it does not exist
        SQL = "INSERT INTO refer(citation,link) VALUES(%s,%s) RETURNING cd_ref"
        cursor.execute(SQL,[ref_citation, ref_link])
        cdRef, = cursor.fetchone()
    # it should return the id of the source in the database
    return cdRef