擷取文件資料
在這個練習中,你會練習使用 json_extract_path 與 json_extract_path_text 來查詢 nested_reviews 資料表中 review 欄位的內容,如下圖所示。

已建立連線物件並存於變數 db_engine,且已將 pandas 以 pd 名稱匯入。祝你順利!
本練習屬於課程
NoSQL 入門
練習說明
- 使用
json_extract_path函式,查詢nested_reviews資料表中review欄位裡statement欄位的值。 - 使用
json_extract_path_text函式,查詢巢狀的reviewer欄位。 - 進一步調整查詢,只保留從 JSON 資料中以文字擷取的
branch資訊等於'Disneyland_California'的紀錄。請使用合適的函式穿越 JSON 結構並鎖定此欄位以進行篩選。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Return the statement and reviewer fields, filter by the
# nested branch field
query = """
SELECT
____(review, '____'),
____
FROM nested_reviews
WHERE ____(____, '____', '____') = 'Disneyland_California';
"""
data = pd.read_sql(query, db_engine)
print(data)