BaşlayınÜcretsiz Başlayın

Executing queries with sqlalchemy and pandas

To work with data stored in Postgres tables, you'll use sqlalchemy's create_engine(), and pandas's read_sql() functions. To get the hang of these tools, you'll practice connecting to a Postgres database, and executing a query. Good luck!

Bu egzersiz

Introduction to NoSQL

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Update the connection URI to create a connection to the disneyland database, over port 5432.
  • Use pandas to read the results of the provided SQL query into a DataFrame, using the connection object created in the previous step.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

import pandas as pd
import sqlalchemy

# Create a connection to the reviews database
db_engine = sqlalchemy.____("postgresql+psycopg2://repl:password@localhost:____/____")

# Execute a query against the nested_reviews table
results = pd.____("SELECT * FROM nested_reviews;", ____)
print(results)
Kodu Düzenle ve Çalıştır