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

Connected

Exercise

Converting tabular data to JSON

Sometimes, data is loaded to a Postgres table using INSERT INTO, or COPY ... FROM commands. Other times, it's generated from an existing table or set of columns. In this exercise, you'll explore some of Postgres' built-in tooling to create a JSON object.

To help get you started, pandas has been imported as pd, and a connection object has been created and stored in the variable db_engine. Good luck!

Instructions

100 XP
  • Use the row_to_json function to convert the review_id, rating, and year_month columns to a single column of type JSON.
  • Execute the query, and print the first ten rows of the resulting DataFrame. Inspect the table to confirm the row_to_json function worked as expected.