開始使用免費開始

查詢欄式資料庫

在這個例子中,你將使用 Snowflake 查詢 olympic_medals 資料表中的資料。這個資料表包含自 1896 年以來的奧運獎牌得主資訊。為了存取儲存在 Snowflake 中的這些資料,你會使用 snowflake.connector 套件。已建立一個連線物件,並存放在變數 conn 中。祝你順利!

本練習屬於課程

NoSQL 入門

檢視課程

練習說明

  • 更新 query 變數中的字串,查回 olympic_medals 資料表的所有欄位,並限制為前 10 列。
  • 使用 conn.cursor().execute() 函式執行儲存在 query 變數中的查詢。
  • 列印查詢結果,結果已存放在 results 變數中。

動手互動練習

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

# Write a query to return all columns, limiting to 10 rows
query = "SELECT * FROM ____ LIMIT 10;"

# Execute the query
results = conn.cursor().execute(____).fetch_pandas_all()

# Print the results of the query
print(____)
編輯並執行程式碼