0 votes
asked May 28 by datalab (1,610 points) | 3 views

1 Answer

0 votes

Saving results to virtual storage using Storage Manager

Now we want to save the results from the a query to our virtual storage space. By putting the query in a try-block we are able to trap errors when executing the query.

    response = queryClient.query (token, adql=query, fmt='csv', 
except Exception as e:
    # Handle any errors in the query.  By running this cell multiple times with the same
    # output file, or by using a bogus SQL statement, you can view various error messages.
    print (e.message)
    if response is not None: 
        print (response)           # print the response
        print ("OK")

Saving results to virtual storage using the datalab command

Now we'll save the results to our virtual storage space as a file. Note that the initial login above has saved our identity token which will be passed automatically with the query. Afterward, we'll list the virtual storage space to confirm the file was saved.

# Login again to access Virtual Storage
!datalab login user=demo00 password=password

!datalab query out='vos://smash_mags.csv'  \
    sql='select id,gmag,rmag,imag from smash_dr1.object limit 10000'
!datalab ls name=vos://
answered Aug 8 by pnorris (240 points)
edited Aug 8 by pnorris

59 questions

39 answers


12 users

Welcome to Data Lab Help Desk, where you can ask questions and receive answers from other members of the community.