spotify-to-sqlite

raw JSON →
0.2.1 verified Sat May 09 auth: no python

Converts a Spotify export ZIP file into a SQLite database. Current version 0.2.1, released Jun 2023. Low activity, maintained as needed.

pip install spotify-to-sqlite
error Usage: spotify-to-sqlite [OPTIONS] COMMAND [ARGS]... Try 'spotify-to-sqlite --help' for help. Error: No such command 'convert'.
cause User has an old version (<0.2) and tries `convert` subcommand.
fix
Upgrade to spotify-to-sqlite>=0.2 with pip install --upgrade spotify-to-sqlite.
error TypeError: 'NoneType' object is not subscriptable
cause Missing or malformed ZIP file; often happens when file path is incorrect.
fix
Verify the ZIP file path and ensure it's a valid Spotify data export.
error spotipy.oauth2.SpotifyOauthError: You need to set your Spotify API credentials.
cause Missing SPOTIPY_CLIENT_ID or SPOTIPY_CLIENT_SECRET environment variables when using --audio-features.
fix
Set environment variables: SPOTIPY_CLIENT_ID='your_id' SPOTIPY_CLIENT_SECRET='your_secret'.
breaking The default command changed from `spotify-to-sqlite my_spotify_data.zip spotify.db` to `spotify-to-sqlite convert my_spotify_data.zip spotify.db` in v0.2.
fix Use the `convert` subcommand: `spotify-to-sqlite convert <input> <output>`
deprecated The `--recreate` flag in v0.1.1+ replaces the old default of overwriting the database. Not a breaking change but behavior differs from v0.1.
fix To overwrite an existing database, use `--recreate`.
gotcha Audio features require Spotify API credentials (SPOTIPY_CLIENT_ID, SPOTIPY_CLIENT_SECRET). Without them, `--audio-features` fails silently or errors.
fix Set environment variables SPOTIPY_CLIENT_ID and SPOTIPY_CLIENT_SECRET before running with `--audio-features`.

Basic usage via subprocess; CLI converts export to database.

# Convert a Spotify export zip to SQLite
db_path = 'spotify.db'
# Run CLI command: spotify-to-sqlite convert my_spotify_data.zip spotify.db
import subprocess
subprocess.run(['spotify-to-sqlite', 'convert', 'my_spotify_data.zip', db_path])
# Or use with audio features:
# spotify-to-sqlite convert my_spotify_data.zip spotify.db --audio-features