# Manage db entries from outside

**URL:** <https://forums.plex.tv/t/manage-db-entries-from-outside/855757>\
**Category:** Apps & Creations\
**Tags:** server-linux\
**Created:** [October 4, 2023, 2:29pm UTC](https://forums.plex.tv/t/manage-db-entries-from-outside/855757 "2023-10-04T14:29:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![michaelrittweger](https://avatars.discourse-cdn.com/v4/letter/m/ad7895/32.png) [@michaelrittweger](https://forums.plex.tv/u/michaelrittweger)\
**Post date:** [October 4, 2023, 2:29pm UTC](https://forums.plex.tv/t/manage-db-entries-from-outside/855757/1 "2023-10-04T14:29:57Z")

</div>

Hi, all!

As far as I can see the database on my Linux machine (Debian) is stored at  
/var/lib/plexmediaserver/Library/Application Support/Plex Media Server  
(contains 2 directories with movies ~1600, 1 directory with tv-shows ~2900 episodes)

What I want to achieve: I need a tool to manipulate the “collection” info for the media in my “library” entries. I don’t want to click on every entry, click on “…”, click on “add to”, click on “add to collection”, select a collection etc. So I think of a browser for the entries row by row where I can mark multiple entries and set the “collection” info for all of the marked rows.

Actually I marked a lot of entries by “smart collection” filters. But it is a bit exhausting to find entries that don’t match the actual filter. So I would like to see something like "[_] - media (e.g. movie title) - description (e.g. content) - collection(s)" and then be able to mark [X] or unmark [_] it and finally set the collection info. A filter for entries without a collection (yet) would be a nice add-on.

I should be able to code a program for this task, but I don’t find info about the structure of the database. And all “manipulate” guides refer to the web interface (and thus, a lot of mouse clicks).

So I ask you if there already is such a tool or where the database structure is documented.

Thanks  
Michael

---

<div class="post-metadata">

**Author:** ![DTR](https://avatars.discourse-cdn.com/v4/letter/d/9fc348/32.png) [@DTR](https://forums.plex.tv/u/DTR)\
**Post date:** [October 4, 2023, 4:44pm UTC](https://forums.plex.tv/t/manage-db-entries-from-outside/855757/2 "2023-10-04T16:44:59Z")

</div>

> [@michaelrittweger](#):
>
> So I think of a browser for the entries row by row where I can mark multiple entries and set the “collection” info for all of the marked rows.

You can use [multiselect](https://support.plex.tv/articles/200392126-using-the-library-view/) to do this ([https://i.imgur.com/ypQ37qk.mp4](https://i.imgur.com/ypQ37qk.mp4)), and use Table View if you want the row-by-row view:  
 ![image](https://global.discourse-cdn.com/plex/original/4X/f/0/a/f0a13755892374f6e396c2c3bdfb613a5400d6d4.png)

As far as automating the process, it would probably be easier to use something like [Python-PlexAPI](https://python-plexapi.readthedocs.io/en/latest/introduction.html) opposed to modifying the database directly.

If you’re still interested in looking into the database, I don’t know of any official documentation, but collection information is spread across three tables:

1. The `tags_collections` column of the `metadata_items` table, represented as a pipe (`|`) separated list of collections.

2. Each unique collection has an entry in the `tag` table with a `tag_type` of 2.

3. For each `metadata_item` that is part of a collection, there’s an entry in the `taggings` table:

You have to use [Plex SQLite](https://support.plex.tv/articles/repair-a-corrupted-database/#toc-1) to edit some tables like `metadata_items`, since it uses custom SQLite extensions that aren’t part of the standard distribution.

---

<div class="post-metadata">

**Author:** ![michaelrittweger](https://avatars.discourse-cdn.com/v4/letter/m/ad7895/32.png) [@michaelrittweger](https://forums.plex.tv/u/michaelrittweger)\
**Post date:** [October 4, 2023, 7:11pm UTC](https://forums.plex.tv/t/manage-db-entries-from-outside/855757/3 "2023-10-04T19:11:30Z")

</div>

Hi, drahn!

Thank you very much for your answer. I think it will push me into the right direction.

The Python-PlexAPI will def. be interesting for me. In fact I was looking for some kind of API to get access to the database, instead of re-inventing the wheel.

And there’s no off. doc. then? Thought so, because I didn’t find any, too. But I wasn’t sure if I had used the right keywords for a search.

But I have a problem locating the database files itself. Below that above mentioned dir. I only see a bunch of “xxx.bundle” dirs which I thought to be the database. But now I think there is some SQL server involved? You talked about SQLite?

Michael

---

<div class="post-metadata">

**Author:** ![DTR](https://avatars.discourse-cdn.com/v4/letter/d/9fc348/32.png) [@DTR](https://forums.plex.tv/u/DTR)\
**Post date:** [October 4, 2023, 9:04pm UTC](https://forums.plex.tv/t/manage-db-entries-from-outside/855757/4 "2023-10-04T21:04:12Z")

</div>

> [@michaelrittweger](#):
>
> And there’s no off. doc. then?

No, modifying the database directly isn’t something that’s officially supported, so there’s no official documentation on its layout, and is subject to change between updates.

> But I have a problem locating the database files itself.

Above the section on finding Plex SQLite, there’s also a section explaining that the database file is " located at `/Plug-in Support/Databases/com.plexapp.plugins.library.db` inside the main Plex Media Server [data directory](https://support.plex.tv/articles/202915258-where-is-the-plex-media-server-data-directory-located/)." It doesn’t live alongside Plex SQLite itself.

> But now I think there is some SQL server involved? You talked about SQLite?

Yes, the Plex database uses sqlite3, but as mentioned above, with custom extensions that require using Plex SQLite to edit some tables instead of e.g. the version you’ll find on the [official SQLite download page](https://sqlite.org/download.html).
