MulaiMulai sekarang secara gratis

Building functions to extract data

It's important to modularize code when building a data pipeline. This helps to make pipelines more readable and reusable, and can help to expedite troubleshooting efforts. Creating and using functions for distinct operations in a pipeline can even help when getting started on a new project by providing a framework to begin development.

pandas has been imported as pd, and sqlalchemy is ready to be used.

Latihan ini adalah bagian dari kursus

ETL and ELT in Python

Lihat Kursus

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

def extract():
  	# Create a connection URI and connection engine
    connection_uri = "postgresql+psycopg2://repl:password@localhost:____/____"
    db_engine = sqlalchemy.____(connection_uri)
Edit dan Jalankan Kode