Use this skill when you need to inspect, query, maintain, or carefully modify the MoviePilot database. This skill uses the bundled scripts/mp-db.py helper, which reads MoviePilot local settings itself and never requires database passwords or full PostgreSQL DSNs in the agent prompt. Applicable scenarios include data statistics, counts, aggregations, inspecting or fixing records, cleanup requests, and questions like "how many downloads", "show site stats", "delete old records", or "why is this subscription stuck".
75
93%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
All script paths are relative to this skill file.
Use scripts/mp-db.py for all database access. Do not extract database passwords, API tokens, or full PostgreSQL DSNs from the prompt. The script reads MoviePilot local settings and connects to SQLite or PostgreSQL internally.
This skill is the direct SQL boundary. It is implemented as a Python script and is appropriate when the agent must inspect records, run data statistics, repair stuck state, or perform an explicitly requested database update.
Prefer safer product surfaces first:
| Request | Preferred skill |
|---|---|
| Normal local MoviePilot product operation exposed as an MCP tool | moviepilot-cli |
| Direct REST endpoint call | moviepilot-api |
| Slash commands or plugin/system command dispatch | command-dispatch |
| Manual file organization | organize-files |
| Retry failed transfer history records | transfer-failed-retry |
Use this skill as the final fallback for data access or mutation. It may run
SELECT, INSERT, UPDATE, DELETE, and schema-changing statements through
the bundled script, but broad or destructive writes still require explicit user
authorization.
List tables:
python scripts/mp-db.py tablesShow table schema:
python scripts/mp-db.py schema downloadhistoryRun a read query:
python scripts/mp-db.py query "SELECT COUNT(*) AS total FROM downloadhistory"Read SQL from stdin or a file:
python scripts/mp-db.py query --file /path/to/query.sqlRun a write statement:
python scripts/mp-db.py write "UPDATE subscribe SET state = 'S' WHERE id = 123"query --write is also supported for compatibility, but prefer the write subcommand for INSERT, UPDATE, DELETE, and schema changes.
tables first, then schema <table>.SELECT queries, execute directly with a narrow projection and an explicit LIMIT when reading rows.INSERT, UPDATE, DELETE, DROP, ALTER, TRUNCATE, CREATE, or REPLACE, use write and report the affected row count.query defaults to read-only mode.write executes data updates and schema-changing statements directly.query --write remains available as a compatibility alias for write statements.SELECT queries get a default LIMIT 100 if no limit is present.DELETE, DROP, or TRUNCATE.UPDATE or DELETE without a WHERE clause unless the user explicitly intends to affect all rows.Key columns: id, path, type, title, year, tmdbid, imdbid, doubanid, seasons, episodes, downloader, download_hash, torrent_name, torrent_site, userid, username, date, media_category
Key columns: id, downloader, download_hash, fullpath, savepath, filepath, torrentname, state
Key columns: id, src, dest, mode, type, category, title, year, tmdbid, seasons, episodes, download_hash, status, errmsg, date
Key columns: id, name, year, type, tmdbid, doubanid, season, total_episode, start_episode, lack_episode, state, filter, include, exclude, quality, resolution, sites, best_version, best_version_full, date, username
Key columns: id, name, year, type, tmdbid, doubanid, season, total_episode, start_episode, date, username
Key columns: id, name, email, is_active, is_superuser, permissions, settings
Key columns: id, name, domain, url, pri, cookie, proxy, is_active, downloader, limit_interval, limit_count
Key columns: id, domain, name, username, user_level, bonus, upload, download, ratio, seeding, leeching, seeding_size, updated_day
Key columns: id, domain, success, fail, seconds, lst_state, lst_mod_date
Key columns: id, server, library, item_id, item_type, title, original_title, year, tmdbid, imdbid, tvdbid, path
Key columns: id, key, value
Key columns: id, username, key, value
Key columns: id, plugin_id, key, value
Key columns: id, channel, source, mtype, title, text, image, link, userid, reg_time
Key columns: id, name, description, timer, trigger_type, event_type, state, run_count, actions, flows, last_time
Key columns: id, user_id, credential_id, public_key, name, created_at, last_used_at, is_active
Key columns: id, name, domain, url, base64
Total downloads:
SELECT COUNT(*) AS total FROM downloadhistoryRecent download history:
SELECT title, year, type, torrent_site, date FROM downloadhistory ORDER BY id DESC LIMIT 10Failed transfers:
SELECT id, title, src, errmsg, date FROM transferhistory WHERE status = 0 ORDER BY id DESC LIMIT 10Active subscriptions:
SELECT name, year, type, season, state, lack_episode FROM subscribe WHERE state = 'R' LIMIT 50Site upload/download statistics:
SELECT name, domain, upload, download, ratio, bonus, seeding, user_level FROM siteuserdata ORDER BY upload DESC LIMIT 50Media library statistics:
SELECT server, library, COUNT(*) AS count FROM mediaserveritem GROUP BY server, librarySite access success rate:
SELECT domain, success, fail, ROUND(success * 100.0 / (success + fail), 1) AS success_rate FROM sitestatistic WHERE success + fail > 0 ORDER BY success_rate DESC LIMIT 50Plugin data keys:
SELECT plugin_id, key FROM plugindata ORDER BY plugin_id, key LIMIT 100| Feature | SQLite | PostgreSQL |
|---|---|---|
| Boolean values | 0 / 1 | false / true |
| String concat | ` | |
| Current time | datetime('now') | NOW() |
| JSON access | json_extract(col, '$.key') | col->>'key' |
| Case-insensitive match | LIKE | ILIKE |
moviepilot doctor.python scripts/mp-db.py tables, then inspect the table with schema.1b065cc
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.