開始使用免費開始

查詢文件型資料庫

使用 Postgres JSON 查詢文件資料的方式,與在 Postgres 查詢關聯式資料相當類似。在這個練習中,你將練習撰寫查詢,從 nested_reviews 資料表中以 Postgres JSON 取回文件資料。祝你查詢順利!

本練習屬於課程

NoSQL 入門

檢視課程

練習說明

  • 更新查詢,從 nested_reviews 資料表回傳 review 欄位。
  • 使用合適的 pandas 函式,利用變數 query 中的邏輯建立一個 DataFrame。
  • 輸出執行查詢後回傳之 DataFrame 的第一筆紀錄。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Update the query to select the review field
query = """
	SELECT 
    	____
    FROM nested_reviews;
"""

# Execute the query
data = ____.____(query, db_engine)

# Print the first element of the DataFrame
____(data.iloc[0, 0])
編輯並執行程式碼