mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-26 02:36:10 +00:00
Merge pull request #209 from druscoe/reduce_execute_and_fetch_one_calls
Reduce execute and fetch one calls
This commit is contained in:
commit
4806379a25
3 changed files with 12 additions and 48 deletions
|
@ -40,11 +40,6 @@ class Kodi(object):
|
||||||
|
|
||||||
return self.cursor.fetchone()[0] + 1
|
return self.cursor.fetchone()[0] + 1
|
||||||
|
|
||||||
def create_entry_person(self):
|
|
||||||
self.cursor.execute(QU.create_person)
|
|
||||||
|
|
||||||
return self.cursor.fetchone()[0] + 1
|
|
||||||
|
|
||||||
def create_entry_genre(self):
|
def create_entry_genre(self):
|
||||||
self.cursor.execute(QU.create_genre)
|
self.cursor.execute(QU.create_genre)
|
||||||
|
|
||||||
|
@ -163,11 +158,8 @@ class Kodi(object):
|
||||||
self.cursor.executemany(sql, parameters)
|
self.cursor.executemany(sql, parameters)
|
||||||
|
|
||||||
def add_person(self, *args):
|
def add_person(self, *args):
|
||||||
|
self.cursor.execute(QU.add_person, args)
|
||||||
person_id = self.create_entry_person()
|
return self.cursor.lastrowid
|
||||||
self.cursor.execute(QU.add_person, (person_id,) + args)
|
|
||||||
|
|
||||||
return person_id
|
|
||||||
|
|
||||||
def _get_person(self, *args):
|
def _get_person(self, *args):
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -37,16 +37,6 @@ class Movies(Kodi):
|
||||||
|
|
||||||
return self.cursor.fetchone()[0] + 1
|
return self.cursor.fetchone()[0] + 1
|
||||||
|
|
||||||
def create_entry_set(self):
|
|
||||||
self.cursor.execute(QU.create_set)
|
|
||||||
|
|
||||||
return self.cursor.fetchone()[0] + 1
|
|
||||||
|
|
||||||
def create_entry_country(self):
|
|
||||||
self.cursor.execute(QU.create_country)
|
|
||||||
|
|
||||||
return self.cursor.fetchone()[0] + 1
|
|
||||||
|
|
||||||
def get(self, *args):
|
def get(self, *args):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -114,11 +104,8 @@ class Movies(Kodi):
|
||||||
self.cursor.execute(QU.update_country, (self.get_country(country),) + args)
|
self.cursor.execute(QU.update_country, (self.get_country(country),) + args)
|
||||||
|
|
||||||
def add_country(self, *args):
|
def add_country(self, *args):
|
||||||
|
self.cursor.execute(QU.add_country, args)
|
||||||
country_id = self.create_entry_country()
|
return self.cursor.lastrowid
|
||||||
self.cursor.execute(QU.add_country, (country_id,) + args)
|
|
||||||
|
|
||||||
return country_id
|
|
||||||
|
|
||||||
def get_country(self, *args):
|
def get_country(self, *args):
|
||||||
|
|
||||||
|
@ -130,11 +117,8 @@ class Movies(Kodi):
|
||||||
return self.add_country(*args)
|
return self.add_country(*args)
|
||||||
|
|
||||||
def add_boxset(self, *args):
|
def add_boxset(self, *args):
|
||||||
|
self.cursor.execute(QU.add_set, args)
|
||||||
set_id = self.create_entry_set()
|
return self.cursor.lastrowid
|
||||||
self.cursor.execute(QU.add_set, (set_id,) + args)
|
|
||||||
|
|
||||||
return set_id
|
|
||||||
|
|
||||||
def update_boxset(self, *args):
|
def update_boxset(self, *args):
|
||||||
self.cursor.execute(QU.update_set, args)
|
self.cursor.execute(QU.update_set, args)
|
||||||
|
|
|
@ -12,10 +12,6 @@ create_file = """
|
||||||
SELECT coalesce(max(idFile), 0)
|
SELECT coalesce(max(idFile), 0)
|
||||||
FROM files
|
FROM files
|
||||||
"""
|
"""
|
||||||
create_person = """
|
|
||||||
SELECT coalesce(max(actor_id), 0)
|
|
||||||
FROM actor
|
|
||||||
"""
|
|
||||||
create_genre = """
|
create_genre = """
|
||||||
SELECT coalesce(max(genre_id), 0)
|
SELECT coalesce(max(genre_id), 0)
|
||||||
FROM genre
|
FROM genre
|
||||||
|
@ -44,14 +40,6 @@ create_movie = """
|
||||||
SELECT coalesce(max(idMovie), 0)
|
SELECT coalesce(max(idMovie), 0)
|
||||||
FROM movie
|
FROM movie
|
||||||
"""
|
"""
|
||||||
create_set = """
|
|
||||||
SELECT coalesce(max(idSet), 0)
|
|
||||||
FROM sets
|
|
||||||
"""
|
|
||||||
create_country = """
|
|
||||||
SELECT coalesce(max(country_id), 0)
|
|
||||||
FROM country
|
|
||||||
"""
|
|
||||||
create_musicvideo = """
|
create_musicvideo = """
|
||||||
SELECT coalesce(max(idMVideo), 0)
|
SELECT coalesce(max(idMVideo), 0)
|
||||||
FROM musicvideo
|
FROM musicvideo
|
||||||
|
@ -233,8 +221,8 @@ VALUES (?, ?, ?)
|
||||||
"""
|
"""
|
||||||
add_file_obj = ["{PathId}", "{Filename}"]
|
add_file_obj = ["{PathId}", "{Filename}"]
|
||||||
add_person = """
|
add_person = """
|
||||||
INSERT INTO actor(actor_id, name)
|
INSERT INTO actor(name)
|
||||||
VALUES (?, ?)
|
VALUES (?)
|
||||||
"""
|
"""
|
||||||
add_people_movie_obj = ["{People}", "{MovieId}", "movie"]
|
add_people_movie_obj = ["{People}", "{MovieId}", "movie"]
|
||||||
add_people_mvideo_obj = ["{People}", "{MvideoId}", "musicvideo"]
|
add_people_mvideo_obj = ["{People}", "{MvideoId}", "musicvideo"]
|
||||||
|
@ -319,12 +307,12 @@ add_unique_id_movie_obj = ["{Unique}", "{MovieId}", "movie", "{UniqueId}", "{Pro
|
||||||
add_unique_id_tvshow_obj = ["{Unique}", "{ShowId}", "tvshow", "{UniqueId}", "{ProviderName}"]
|
add_unique_id_tvshow_obj = ["{Unique}", "{ShowId}", "tvshow", "{UniqueId}", "{ProviderName}"]
|
||||||
add_unique_id_episode_obj = ["{Unique}", "{EpisodeId}", "episode", "{UniqueId}", "{ProviderName}"]
|
add_unique_id_episode_obj = ["{Unique}", "{EpisodeId}", "episode", "{UniqueId}", "{ProviderName}"]
|
||||||
add_country = """
|
add_country = """
|
||||||
INSERT INTO country(country_id, name)
|
INSERT INTO country(name)
|
||||||
VALUES (?, ?)
|
VALUES (?)
|
||||||
"""
|
"""
|
||||||
add_set = """
|
add_set = """
|
||||||
INSERT INTO sets(idSet, strSet, strOverview)
|
INSERT INTO sets(strSet, strOverview)
|
||||||
VALUES (?, ?, ?)
|
VALUES (?, ?)
|
||||||
"""
|
"""
|
||||||
add_set_obj = ["{Title}", "{Overview}"]
|
add_set_obj = ["{Title}", "{Overview}"]
|
||||||
add_musicvideo = """
|
add_musicvideo = """
|
||||||
|
|
Loading…
Reference in a new issue