mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-24 17:56:11 +00:00
use the new context Db connection class
use closing helper to auto close cousor when it goes out of context
This commit is contained in:
parent
a763cd37c9
commit
4701041d99
1 changed files with 17 additions and 16 deletions
|
@ -9,6 +9,8 @@ import xbmc
|
|||
|
||||
import downloadutils
|
||||
from utils import window, settings, kodiSQL
|
||||
from database import DatabaseConn
|
||||
from contextlib import closing
|
||||
|
||||
#################################################################################################
|
||||
|
||||
|
@ -102,16 +104,16 @@ class Read_EmbyServer():
|
|||
viewId = view['Id']
|
||||
|
||||
# Compare to view table in emby database
|
||||
emby = kodiSQL('emby')
|
||||
cursor_emby = emby.cursor()
|
||||
with DatabaseConn('emby') as conn:
|
||||
with closing(conn.cursor()) as cursor:
|
||||
query = ' '.join((
|
||||
|
||||
"SELECT view_name, media_type",
|
||||
"FROM view",
|
||||
"WHERE view_id = ?"
|
||||
))
|
||||
cursor_emby.execute(query, (viewId,))
|
||||
result = cursor_emby.fetchone()
|
||||
cursor.execute(query, (viewId,))
|
||||
result = cursor.fetchone()
|
||||
try:
|
||||
viewName = result[0]
|
||||
mediatype = result[1]
|
||||
|
@ -119,7 +121,6 @@ class Read_EmbyServer():
|
|||
viewName = None
|
||||
mediatype = None
|
||||
|
||||
cursor_emby.close()
|
||||
|
||||
return [viewName, viewId, mediatype]
|
||||
|
||||
|
|
Loading…
Reference in a new issue