Filtering document databases with Postgres JSON
Using Postgres JSON, data stored in documents can be queried and filtered using the -> and ->> operators. To practice, you'll filter reviews using Postgres JSON. Similar to before, the nested_reviews table takes the form below, and a sqlalchemy connection object has been configured, and made available for you via the db_engine variable. pandas has also been loaded as pd.

Questo esercizio fa parte del corso
Introduction to NoSQL
Istruzioni dell'esercizio
- Use Postgres JSON to retrieve the value stored at the
statementkey in thereviewcolumn, for each record in thenested_reviewstable. - Only return results with a
branchnested in thelocationobject of thereviewcolumn equal to'Disneyland_California'.
Esercizio pratico interattivo
Prova a risolvere questo esercizio completando il codice di esempio.
# Build the query to select the rid and rating fields
query = """
SELECT
review ____ '____' AS customer_review
FROM nested_reviews
WHERE review ____ '____' ____ '____' = 'Disneyland_California';
"""
# Execute the query, render results
data = pd.read_sql(query, db_engine)
print(data)