예제 #1
0
def listSeriesByCategory(id):
    id = str(id)
    with dbConnect() as cursor:
        cursor.execute(
            "SELECT Name, Description FROM Series where Category LIKE ?",
            ("%" + id + ",%", ))
        return cursor.fetchall()
예제 #2
0
def getCategoryIdByName(name):
    id_list = []
    for n in name:
        with dbConnect() as cursor:
            cursor.execute(
                'SELECT CategoryId FROM Category where Description = ?', (n, ))
            id_list.append(cursor.fetchone()[0])
    return id_list
예제 #3
0
def addNewUser(data):
    with dbConnect() as cursor:
        cursor.execute(
            'Insert INTO User(Username,Password, Role) Values(?,?,?)', (
                data["Username"],
                data["Password"],
                data["Role"],
            ))
        return cursor.fetchall()
예제 #4
0
def addNewSeries(data):
    with dbConnect() as cursor:
        cursor.execute(
            'INSERT INTO Series(Name,Description,Category) '
            'Values(?,?,?)', (
                data["Name"],
                data["Description"],
                data["Category"],
            ))
        print("Insert Successful")
        return cursor.fetchone()
예제 #5
0
def addNewEpisode(data):
    with dbConnect() as cursor:
        cursor.execute(
            'INSERT INTO Episodes(Name,Description,Series,EpisodeNumber,SeasonNumber,FileLocation,DateAdded) '
            'Values(?,?,?,?,?,?,?)', (
                data["Name"],
                data["Description"],
                data["Series"],
                data["EpisodeNumber"],
                data["SeasonNumber"],
                data["FileLocation"],
                data["DateAdded"],
            ))
        return cursor.fetchall()
예제 #6
0
def listAllCategories():
    with dbConnect() as cursor:
        cursor.execute('SELECT CategoryId,Description FROM Category')
        return cursor.fetchall()
예제 #7
0
def addNewCategory(data):
    with dbConnect() as cursor:
        cursor.execute("INSERT INTO Category(Description) Values(?)",
                       (data["Description"], ))
예제 #8
0
def getCategoryNameById(id):
    with dbConnect() as cursor:
        cursor.execute('SELECT Description FROM Category where CategoryId = ?',
                       (id, ))
        return cursor.fetchone()
예제 #9
0
def getRoleIdFromName(name):
    with dbConnect() as cursor:
        cursor.execute('SELECT RoleId FROM Roles where Description = ?',
                       (name, ))
        return cursor.fetchall()
예제 #10
0
def listAllRoles():
    with dbConnect() as cursor:
        cursor.execute('SELECT Description FROM Roles')
        return cursor.fetchall()
예제 #11
0
def getSeriesIdByName(name):
    with dbConnect() as cursor:
        cursor.execute('SELECT SeriesId FROM Series where Name = ?', (name, ))
        return cursor.fetchone()
예제 #12
0
def listAllSeries():
    with dbConnect() as cursor:
        cursor.execute('SELECT SeriesId, Name,Description FROM Series')
        return cursor.fetchall()
예제 #13
0
def listAllUsers():
    with dbConnect() as cursor:
        cursor.execute('SELECT Username, Psssword FROM User')
        return cursor.fetchall()
예제 #14
0
def listAllEpisodes():
    with dbConnect() as cursor:
        cursor.execute(
            'SELECT Name, Description,EpisodeNumber, SeasonNumber, FileLocation FROM Episodes'
        )
        return cursor.fetchall()
예제 #15
0
def getEpisodeByEpisodeId(id):
    with dbConnect() as cursor:
        cursor.execute(
            "SELECT Name, Description,EpisodeNumber, SeasonNumber, FileLocation from Episodes WHERE EpisodeId = ?",
            (id, ))
        return cursor
예제 #16
0
def listAllEpisodesBySeries(series):
    with dbConnect() as cursor:
        cursor.execute(
            "SELECT e.EpisodeId, e.Name, e.EpisodeNumber, e.SeasonNumber FROM Episodes e inner join Series s on s.SeriesId = e.Series where s.Name = ?",
            (series, ))
        return cursor.fetchall()
예제 #17
0
def listRecentEpisodes():
    with dbConnect() as cursor:
        cursor.execute(
            'SELECT Name, Description,EpisodeNumber, SeasonNumber, FileLocation FROM Episodes ORDER BY DateAdded desc LIMIT 5'
        )
        return cursor.fetchall()
예제 #18
0
def VerifyUser(un, ps):
    with dbConnect() as cursor:
        cursor.execute(
            'SELECT Username, Password, Role FROM User WHERE Username = ? and Password = ?',
            (un, ps))
        return cursor.fetchall()