From f5a7d411051d3112a90e26f1e382dc1e00fb9a00 Mon Sep 17 00:00:00 2001 From: Arno Date: Wed, 16 Jun 2010 22:45:24 +0200 Subject: Treemodel Development -Changed the database schema. Attached quality to files -Subclassed SmTreeModel for SeriesTreeModel -Made SmTreeModel virtual for that Well, it seems there is a serious problem with the database schema. Curiously everything inside the model works beside the db update. Seems I have it wrong with the fks :( --- migdb.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'migdb.py') diff --git a/migdb.py b/migdb.py index 56eb8e9..d262ce9 100644 --- a/migdb.py +++ b/migdb.py @@ -78,8 +78,8 @@ class Migrator: def newEntry(self, title, partno, filename, md5, size, dvd, filetype, fileno, genreName, actorNames, quality): seriesid = self.newSeries(title) - seriespartid = self.newSeriesPart(seriesid, partno, quality) - self.newFile(seriespartid, filename, md5, size, dvd, 1, partno) + seriespartid = self.newSeriesPart(seriesid, partno) + self.newFile(seriespartid, filename, md5, size, dvd, 1, partno, quality) genreId = self.genreId(genreName) newCur = self.mNewConn.cursor() if genreId != -1: @@ -129,18 +129,18 @@ class Migrator: self.mNewGenreMap[genreName] = retval return retval - def newFile(self, seriespartid, filename, md5, size, dvd, filetype, fileno): - q1 = "INSERT INTO files(iseriespart_id, tfilename, cmd5sum, bisize, idvd, sifiletype, sifileno) VALUES(%s, %s, %s, %s, %s, %s, %s)" + def newFile(self, seriespartid, filename, md5, size, dvd, filetype, fileno, quality): + q1 = "INSERT INTO files(iseriespart_id, tfilename, cmd5sum, bisize, idvd, sifiletype, sifileno, siquality) VALUES(%s, %s, %s, %s, %s, %s, %s, %s)" cur = self.mNewConn.cursor() try: - cur.execute(q1, (seriespartid, filename, md5, size, dvd, filetype, fileno)) + cur.execute(q1, (seriespartid, filename, md5, size, dvd, filetype, fileno, quality)) except psycopg2.Error as ex: print "Error: %s" %(ex.pgerror, ) self.mNewConn.rollback() self.mNewConn.commit() - def newSeriesPart(self, seriesid, part, quality): + def newSeriesPart(self, seriesid, part): part = part == -1 and 1 or part q1 = "SELECT iseriesparts_id FROM seriesparts WHERE iseries_id = %s AND iseriespart = %s" cur = self.mNewConn.cursor() @@ -148,8 +148,8 @@ class Migrator: spartids = cur.fetchall() retval = -1 if len(spartids) == 0: - q2 = "INSERT INTO seriesparts(iseriespart, iseries_id, iquality) VALUES(%s, %s, %s)" - cur.execute(q2, (part, seriesid, quality)) + q2 = "INSERT INTO seriesparts(iseriespart, iseries_id) VALUES(%s, %s)" + cur.execute(q2, (part, seriesid)) cur.execute("SELECT currval('seriesparts_seriesparts_id__seq')") retval = cur.fetchall()[0][0] self.mNewConn.commit() -- cgit v1.2.3-70-g09d2