This project imports and analyzes Spotify data using PostgreSQL and Python.
Five CSV files are imported into the database:
spotify_artists
spotify_albums
spotify_tracks
spotify_features
spotify_data

The data is then analyzed using basic and analytical SQL queries.
PostgreSQL
β Database management system for data storage.Python
(psycopg2
,pandas
) β For importing CSV files into the database and executing SQL queries.SQL
β For data analysis (LIMIT
,WHERE + ORDER BY
,GROUP BY
,JOIN
, aggregations).- (Optional)
Apache Superset
β For visualization (not required in this project).
# π¦ Install dependencies
pip install pandas psycopg2
# βΆοΈ Run the script
python dv.py
# β
This will:
- Import CSV data into PostgreSQL
- Execute 4 basic queries
- Execute 10 analytical queries
# π Queries Implemented
π’ Basic Queries
- LIMIT β First 10 albums
- WHERE + ORDER BY β Top 20 tracks by popularity
- GROUP BY β Average track popularity by album
- JOIN β Number of tracks per album
π΅ Analytical Queries
- Top 10 artists by number of followers
- Top albums by total track popularity
- Most energetic tracks
- Top albums by danceability
- Distribution of track duration (0β10 minutes)
- Fast and popular tracks (tempo + popularity)
- Artists ranked by number of tracks
- Top explicit tracks by popularity
- Number of tracks by release year
- Average energy by release year
π Project Structure
π¦ Assignment 1 - Spotify Database
βββ dv.py # Main Python script (import + queries)
βββ queries.sql # Collection of SQL queries
βββ Assignment1.pdf # Assignment description
βββ *.csv # Spotify dataset files
β¨ Done β ready to explore Spotify with SQL!