use the new DatabaseCon context class

use closing with for cursor
This commit is contained in:
shaun 2016-11-05 11:51:17 +11:00
parent b3214a9250
commit a58b644062

View file

@ -13,6 +13,8 @@ import embydb_functions as embydb
import musicutils as musicutils
from utils import settings, dialog, language as lang, kodiSQL
from dialogs import context
from database import DatabaseConn
from contextlib import closing
#################################################################################################
@ -87,11 +89,10 @@ class ContextMenu(object):
if not item_id and kodi_id and item_type:
conn = kodiSQL('emby')
cursor = conn.cursor()
with DatabaseConn('emby') as conn:
with closing(conn.cursor()) as cursor:
emby_db = embydb.Embydb_Functions(cursor)
item = emby_db.getItem_byKodiId(kodi_id, item_type)
cursor.close()
try:
item_id = item[0]
except TypeError: