What is a playlist to SQLite exporter?
A playlist to SQLite exporter gives you a YouTube playlist as a ready-made SQLite database file, so you can answer questions about it with SQL instead of formulas: the most viewed videos, the total watch time, the most common tags, or videos published in a given year.
The file has a playlist table and a videos table with one typed column per field you choose. Lists like tags are stored as JSON arrays that SQLite's json_each() can expand. It opens in DB Browser for SQLite, TablePlus, Datasette, the sqlite3 shell, and Python or any language with an SQLite driver, with no server to set up.
How to export a YouTube playlist to SQLite
1.Paste the playlist link
Paste the link of the playlist you want to query and press Export. Large playlists are fetched in full before the database is built.
2.SQLite is already ticked
Pick the columns of the videos table: title, video ID, durations, views, likes, comments, description, tags and more.
3.Download
Press Download to get a .sqlite file and open it in DB Browser for SQLite, the sqlite3 shell or your own code.
Example: the five most viewed videos
With Title and Views ticked, run this query on the downloaded file.
- Query
- SELECT title, views FROM videos ORDER BY views DESC LIMIT 5;
- Returns
- 5 rows: title and view count
- Total hours (with Seconds ticked)
- SELECT sum(seconds) / 3600.0 FROM videos;
Because views is stored as INTEGER, the ordering is numeric, so 9,000 views sorts below 10,000, not above it as text would.
What's in the database
The file has two tables. playlist holds one row with the id, title, channel, url, video_count and exported_at. videos holds one row per video in playlist order, with a column for each field you pick, named in snake_case like video_id and duration_text, and typed INTEGER, REAL or TEXT.
Lists such as tags and description links are stored as JSON arrays, so SQLite's json_each() can split them, and watched is 1 or 0. Try SELECT title, views FROM videos ORDER BY views DESC LIMIT 10.
Frequently asked questions
How do I open the .sqlite file?
Use DB Browser for SQLite or TablePlus, run sqlite3 playlist.sqlite in a terminal, or open it from Python with sqlite3.connect. Datasette can publish it as a website.
How do I count videos per tag?
Tick Tags, then run SELECT tag.value, count(*) FROM videos, json_each(videos.tags) AS tag GROUP BY tag.value ORDER BY 2 DESC.
How do I get the total length of the playlist?
Tick Seconds and run SELECT sum(seconds) / 3600.0 AS hours FROM videos.
Can I combine several playlists in one database?
Each export is its own file. Open one, ATTACH the other, and copy its rows across with INSERT INTO videos SELECT * FROM other.videos.
Export a YouTube playlist to other formats
Related tools
Playlist Length Calculator
Total duration of any playlist at any speed, for all or part of it.
Playlist Study Planner
Turn a playlist into a day-by-day schedule with a finish date.
Course Progress Tracker
Track your progress across several YouTube courses, saved in your browser.
Export YouTube Playlist to Excel
Export a playlist to Excel, CSV, JSON, Word, SQLite, M3U and 7 more formats.
Export YouTube Playlist to CSV
Export a playlist to a CSV file for spreadsheets, databases and scripts.
Export YouTube Playlist to Text
Export a playlist as a plain text list of titles and links.