コード例 #1
0
ファイル: song.py プロジェクト: albertvisser/magiokis
 def write(self):
     if self.url == self.songtitel + ".xml":
         self.url = ""
     if self.found:
         cmd = 'update songs set muziek = "%s",tekst = "%s",titel = "%s",' \
             'datering = "%s",datumtekst = "%s",url = "%s",commentaar = "%s" '\
             'where id == "%s"' % (self.muziek_id, self.tekst_id, self.songtitel,
             self.datering, self.datumtekst, self.url, self.commentaar, self._id)
     else:
         cmd = 'insert into songs (id, muziek, tekst, titel, datering, ' \
             'datumtekst, url, commentaar) values ("%s", "%s", "%s", "%s", ' \
             '"%s", "%s", "%s", "%s")' % (self._id, self.muziek_id, self.tekst_id,
             self.songtitel, self.datering, self.datumtekst, self.url,
             self.commentaar)
     try:
         c = self.con.execute(cmd)
     except sqlite3.OperationalError as mld:
         print(cmd)
         raise common.DataError(mld)
     except BaseException:
         raise common.DataError("Bijwerken mislukt")
     self.con.commit()
     if not self.found:
         dh = CodeRec("laatste", "song")
         dh.item_naam = self._id
         dh.write()
         self.found = True
コード例 #2
0
ファイル: user.py プロジェクト: albertvisser/magiokis
 def read(self):
     cmd = "select * from users where id == '%s'" % self.userid
     try:
         c = self.con.execute(cmd)
     except sqlite3.OperationalError as mld:
         raise common.DataError(mld)
     except:
         ## print self.__dict__
         raise common.DataError("User niet gevonden")
     self.userfound = True
コード例 #3
0
 def __init__(self, file):
     Lijst.__init__(self,file)
     if file not in self.types_omlists:
         raise common.DataError("Onbekend type Ownerlist")
     cur = self.con.cursor()
     c = cur.execute("select distinct id from %s" % self.tbnamen[file])
     data = c.fetchall()
     if data:
         self.lijst = [x[0] for x in data]
     else:
         raise common.DataError("Geen gegevens voor deze Ownerlist")
コード例 #4
0
 def __init__(self, file):
     Lijst.__init__(self,file)
     if file not in self.types_codes:
         raise common.DataError("Codetabel naam onbekend")
     cur = self.con.cursor()
     c = cur.execute("select * from %s" % self.tbnamen[file])
     data = c.fetchall()
     if data:
         self.lijst = {}
         for x in data:
             self.lijst[x[0]] = x[1:]
     else:
         raise common.DataError("Codetabel bevat geen gegevens")
コード例 #5
0
ファイル: song.py プロジェクト: albertvisser/magiokis
 def read(self):
     """songs(id,muziek,tekst,titel,datering,datumtekst,url,commentaar)"""
     try:
         c = self.con.execute(
             'select * from songs '
             'left join auteurs on auteurs.id == songs.tekst '
             'left join makers on makers.id == songs.muziek '
             'where songs.id == ?', (str(self._id), ))
     except sqlite3.OperationalError as mld:
         raise common.DataError("Ophalen mislukt")
     i = 0
     for x in c:
         self._muziek_id = x[1]
         self._tekst_id = x[2]
         self._titel = x[3]
         self.datering = x[4]
         self.datumtekst = x[5]
         self.url = x[6]
         if self.url == "" and self.songtitel != "":
             self.url = self.songtitel + ".xml"
         self.commentaar = x[7]
         self.tekst_van = x[9]
         self.muziek_van = x[11]
         i += 1
     if i > 0:
         self.found = True
コード例 #6
0
 def read(self):
     cmd = 'select * from registraties, songs, regtypes where songs.id == ' \
         'registraties.song and regtypes.id == registraties.type and ' \
         'registraties.id == "%s"' % self._id
     ## print cmd
     try:
         c = self.con.execute(cmd)
     except sqlite3.OperationalError as e:
         print(cmd)
         raise common.DataError("Ophalen mislukt: " + str(e))
     i = 0
     for x in c:
         self._type_id = x[1]
         self._song_id = x[2]
         self._file = x[3]
         self.commentaar = x[4]
         self.songtitel = x[8]
         self.regtype = x[14]
         ## self.player = x[17]
         ## self.editor = x[18]
         self.url = '/'.join((x[16], self._file))
         self.pad = os.path.join(x[15], self._file)
         i += 1
     if i > 0:
         self.found = True
コード例 #7
0
 def __init__(self):
     Lijst.__init__(self)
     self.items = {}
     cur = self.con.cursor()
     c = cur.execute("select id, titel from songs")
     data = c.fetchall()
     if data:
         for x in data:
             self.items[x[0]] = x[1]
     else:
         raise common.DataError("Geen songs gevonden")
コード例 #8
0
ファイル: user.py プロジェクト: albertvisser/magiokis
 def __init__(self, userid, paswd): # user aanmaken
     self.userfound = False
     self.con = sqlite3.connect(common.data)
     self.userid = userid
     self.paswd = paswd
     self.read()
     if self.paswd != dh.password:
         self.paswdok = False
         raise common.DataError("Password mismatch")
     else:
         self.paswdok = True
コード例 #9
0
 def __init__(self, file, attrib, value):
     self.search_attr = attrib
     self.search_val = value
     bezet = ItemList('bezetting').lijst
     m = ItemList("instrument")
     ins = m.lijst
     ins['-'] = ('',)
     Lijst.__init__(self)
     if file not in self.file_attr:
         raise common.DataError("Foutief selectietype opgegeven")
     if attrib not in self.file_attr[file]['attr']:
             raise common.DataError("Foutief attribuut opgegeven")
     selfrom = self.file_attr[file]['selfrom']
     cols = self.file_attr[file]['cols']
     join = self.file_attr[file]['join']
     cur = self.con.cursor()
     sel = '{} and {} = "{}"'.format(join, attrib, value)
     cmd = 'select %s from %s where %s' % (cols, selfrom, sel)
     ## print cmd
     c = cur.execute(cmd)
     data = c.fetchall()
     self.items = {}
     if data:
         for x in data:
             if file == "songs":
                 y = {"Titel": x[1], "Tekst_van": x[2], "Muziek_van": x[3]}
             elif file == "opnames":
                 y = {"Titel": x[1], "Plaats": x[2], "Datum": x[3]}
                 if x[4] != '':
                     y["Bezetting"] = bezet[x[4]][0]
                 if x[5] != '':
                     y["Instrumenten"] = ", ".join([ins[z][0] for z in x[5]])
                 y["Commentaar"] = x[6]
             elif file == "muziek":
                 y = {"Titel": x[1], "File": x[2], "Type": x[3],
                     "Commentaar": x[4]}
             self.items[x[0]] = y
     else:
         raise common.DataError("Geen gegevens gevonden")
コード例 #10
0
 def write(self):
     if self.found:
         cmd = 'update registraties set type = "%s", song = "%s",' \
             'url = "%s", commentaar = "%s" where id == "%s"' % (self._type_id,
             self._song_id, self._file, self.commentaar, self._id)
     else:
         cmd = 'insert into registraties (id, type, song, url, commentaar) ' \
             'values ("%s","%s","%s","%s","%s")' % (self._id, self._type_id,
             self._song_id, self._file, self.commentaar)
     try:
         c = self.con.execute(cmd)
     except sqlite3.OperationalError as mld:
         print(cmd)
         raise common.DataError(mld)
     except:
         raise common.DataError("Bijwerken mislukt")
     self.con.commit()
     if not self.found:
         dh = CodeRec("laatste", "registratie")
         dh.item_naam = self._id
         dh.write()
         self.found = True
コード例 #11
0
 def __init__(self, item, file):
     Lijst.__init__(self,file)
     if file not in self.types_omlists:
         raise common.DataError("Onbekend type Memberlist")
     if file in self.types_omlists[:2]:
         cmd = 'select id from %s where song == "%s"' % (self.tbnamen[file], item)
     elif file == self.types_omlists[2]:
         cmd = ('select {0}.opname,songs.titel,songs.id,opnames.url from '
             "{0}, opnames left outer join songs on opnames.song = songs.id"
             ' where {0}.id = "{1}" and {0}.opname = opnames.id order by'
             ' {0}.rowid'.format(self.tbnamen[file], item))
     elif file in self.types_omlists[3:]:
         cmd = 'select song from %s where id = "%s"' % (self.tbnamen[file], item)
     cur = self.con.cursor()
     ## print cmd
     c = cur.execute(cmd)
     data = c.fetchall()
     if data:
         self.lijst = [x[0] for x in data if x[0] != ""]
         if file == self.types_omlists[2]:
             self.songs = [x[2] for x in data if x[0] != ""]
             self.titels = [x[1] for x in data if x[0] != ""]
             self.urls = [x[3] for x in data if x[0] != ""]
         if len(self.lijst) == 0:
             raise common.DataError("Geen members bij owner")
         self.tekst = ""
         if file == self.types_omlists[2]:
             c = cur.execute('select titel, opgenomen from %s where id = "%s"'
                 ' and opname = ""' % (self.tbnamen[file], item))
             for x in c:
                 self.titel, self.tekst = x[0], x[1]
         elif file in self.types_omlists[4:]:
             c = cur.execute('select tekst from %s where id = "%s" and'
                 ' song = ""' % (self.tbnamen[file], item))
             for x in c:
                 self.tekst = x[0]
     else:
         raise common.DataError("Geen gegevens voor deze Memberlist")
コード例 #12
0
 def read(self):
     cmd = 'select * from regtypes where id == "%s"' % self.type
     try:
         c = self.con.execute(cmd)
     except:
         print(cmd)
         raise common.DataError("Ophalen mislukt")
     i = 0
     for x in c:
         ## self.Type = x[0]
         _, self.typenaam, self.padnaam, self.htmlpadnaam, self.playernaam, \
             self.readernaam = x
         i += 1
     if i > 0:
         self.found = True
コード例 #13
0
 def __init__(self):
     Lijst.__init__(self)
     self.items = {}
     cur = self.con.cursor()
     c = cur.execute("select * from regtypes")
     data = c.fetchall()
     if data:
         tt = [x[0] for x in cur.description]
         for x in data:
             td = {}
             for i in range(1,len(tt)):
                 td[tt[i]] = x[i]
             self.items[x[0]] = td
     else:
         raise common.DataError("Geen regtypes gevonden")
コード例 #14
0
ファイル: opname.py プロジェクト: albertvisser/magiokis
 def write(self):
     if self.found:
         cmd = 'update opnames set plaats = "%s", datum = "%s", somg = "%s"' \
         ', bezetting = "%s",instrumenten = "%s", url = "%s", commentaar = "%s" ' \
         'where id == "%s"' % (self._plaatsid, self._datumid, self._songid,
         self._bezetid, self.url, self.commentaar, self._id)
     else:
         cmd = 'insert into opnames (id, plaats, datum, song, bezetting, ' \
         'instrumenten, url, commentaar) values ("%s", "%s", "%s", "%s", "%s", ' \
         '"%s","%s","%s")' % (self._id, self._plaatsid, self._datumid,
         self._songid, self._bezetid, self.url, self.commentaar)
     try:
         c = self.con.execute(cmd)
     except sqlite3.OperationalError as mld:
         print(cmd)
         raise common.DataError(mld)
     except:
         raise common.DataError("Bijwerken mislukt")
     self.con.commit()
     if not self.found:
         dh = CodeRec("laatste", "opname")
         dh.setAttr("naam", self._id)
         dh.write()
         self.found = True