1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to NoSQL

Connected

Exercise

Querying top-level JSON data

With Postgres JSON, querying semi-structured data is a breeze! Postgres provides built-in operators, including -> and ->>. In this example, you'll practice using these operators to query review data from a column of type JSON. This table takes the form below:

nested_reviews table, showing sample data.

To give you a head-start, pandas has been imported as pd, and a connection object has been created and stored in the db_engine variable. Have fun!

Instructions

100 XP
  • Use the -> operator to query the location field from the review column in the nested_reviews table, as JSON.
  • Query the statement field as text from the review column in the nested_reviews table.
  • Execute the query using pandas, and print the result.