# Alter Table (metadata\_items)

**URL:** <https://forums.plex.tv/t/alter-table-metadata_items/174145>\
**Category:** Dev/API Corner\
**Tags:** plugin-dev\
**Created:** [January 3, 2017, 12:16pm UTC](https://forums.plex.tv/t/alter-table-metadata_items/174145 "2017-01-03T12:16:16Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sophos84](https://avatars.discourse-cdn.com/v4/letter/s/f05b48/32.png) [@Sophos84](https://forums.plex.tv/u/Sophos84)\
**Post date:** [January 3, 2017, 12:16pm UTC](https://forums.plex.tv/t/alter-table-metadata_items/174145/1 "2017-01-03T12:16:16Z")

</div>

Hey,  
Iam need a additional column in the metadata\_items table for my plugin. Iam trying to add these column in the start method of my plugin. But nothing changes.

Heres my code

`def Start(): ObjectContainer.title1 = name ObjectContainer.art = R(art) HTTP.CacheTime = CACHE_1HOUR conn = sqlite3.connect(database) change = True for row in conn.execute('PRAGMA table_info(metadata_items)').fetchall(): if row[1] == prefix + 'Link': change = False if change == True: conn.execute('ALTER TABLE metadata_items ADD COLUMN ' + prefix + 'Link' + ' TEXT;') conn.commit() conn.close()`

---

<div class="post-metadata">

**Author:** ![Sophos84](https://avatars.discourse-cdn.com/v4/letter/s/f05b48/32.png) [@Sophos84](https://forums.plex.tv/u/Sophos84)\
**Post date:** [January 3, 2017, 12:18pm UTC](https://forums.plex.tv/t/alter-table-metadata_items/174145/2 "2017-01-03T12:18:46Z")

</div>

Update: A test with a SQLite editor for alter the table Iam getting a error that says the database is locked. How can I unlocked it without stop the Plex server?

---

<div class="post-metadata">

**Author:** ![dane22](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/dane22/32/4389_2.png) [@dane22](https://forums.plex.tv/u/dane22)\
**Post date:** [January 3, 2017, 8:38pm UTC](https://forums.plex.tv/t/alter-table-metadata_items/174145/3 "2017-01-03T20:38:41Z")

</div>

I can’t help you with that, but I can tell you that the whole idea is bad, and could lead to problems with future upgrades.  
Also note, that not all platforms support direct access to the database. (Windows and Mac only, AFAIK)

/T

---

<div class="post-metadata">

**Author:** ![anon18523487](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@anon18523487](https://forums.plex.tv/u/anon18523487)\
**Post date:** [January 3, 2017, 9:17pm UTC](https://forums.plex.tv/t/alter-table-metadata_items/174145/4 "2017-01-03T21:17:24Z")

</div>

I agree. Modifying the database is a bad idea. You can seriously mess things up. It could also prevent the database from updating if Plex should make a change themselves to that table in the future. Find some other way to store the info you want outside of Plex’s database.

---

<div class="post-metadata">

**Author:** ![Sophos84](https://avatars.discourse-cdn.com/v4/letter/s/f05b48/32.png) [@Sophos84](https://forums.plex.tv/u/Sophos84)\
**Post date:** [January 3, 2017, 9:28pm UTC](https://forums.plex.tv/t/alter-table-metadata_items/174145/5 "2017-01-03T21:28:48Z")

</div>

Hmmm, that is bad. Do you have any recommendations for me? I need only to save a Url to a website for a Serie/Movie in my Plex Mediadatabase. From the Websites I parse recommendations for other Series/Movies and these are Entries from my Channel Plugin.

Another Question: Is there any possibility to add the Url inside Plex?

---

<div class="post-metadata">

**Author:** ![dane22](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/dane22/32/4389_2.png) [@dane22](https://forums.plex.tv/u/dane22)\
**Post date:** [January 3, 2017, 9:37pm UTC](https://forums.plex.tv/t/alter-table-metadata_items/174145/6 "2017-01-03T21:37:35Z")

</div>

Plex Framework does not allows you to add a hyperlink to the gui, if that’s what you are asking.

Note that it’s purpose was/is to stream with a minimistic interface.

Regarding storage, either use the storage API (data) or Dict

See this post:

[forums.plex.tv/discussion/comment/971278/#Comment\_971278](http://forums.plex.tv/discussion/comment/971278/#Comment_971278 "forums.plex.tv/discussion/comment/971278/#Comment\_971278")

/T

---

<div class="post-metadata">

**Author:** ![Sophos84](https://avatars.discourse-cdn.com/v4/letter/s/f05b48/32.png) [@Sophos84](https://forums.plex.tv/u/Sophos84)\
**Post date:** [January 4, 2017, 1:23am UTC](https://forums.plex.tv/t/alter-table-metadata_items/174145/7 "2017-01-04T01:23:33Z")

</div>

Thanks for the infos. now it is clear why it don’t works 😉

A question about the storage API: is there any documentation or tutorial how I must use it. The “Plex Plug-in Framework Documentation” is not useful enough for me (in example: in which place must the files exists to access it)?

---

<div class="post-metadata">

**Author:** ![dane22](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/dane22/32/4389_2.png) [@dane22](https://forums.plex.tv/u/dane22)\
**Post date:** [January 4, 2017, 8:00am UTC](https://forums.plex.tv/t/alter-table-metadata_items/174145/8 "2017-01-04T08:00:43Z")

</div>

That’s all handled internally by the API, and you do not access the file directly, only through the API.

`Data.SaveObject(item, obj) Stores a Python object as a data item with the given name. Parameters • item (str (http://docs.python.org/library/functions.html#str)) – The name of the data item to store. • data (object (http://docs.python.org/library/functions.html#object)) – The Python object to store.`

As such, the physical location of the file is irrelevant.

/T

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/plex/original/3X/2/a/2acb9765406f63293d357b4ec509ec39aa28f2ad.png) [@system](https://forums.plex.tv/u/system)\
**Post date:** [January 8, 2020, 8:01pm UTC](https://forums.plex.tv/t/alter-table-metadata_items/174145/9 "2020-01-08T20:01:11Z")

</div>


