def deleteLanguage(self, Language): #DELETE Query try: q = "DELETE FROM " + self.__tableName + " WHERE id='%i'" % ( Language.getLanguageId()) self.__SQL_Connector.getCursor().execute(q) self.__SQL_Connector.getConection().commit() except Exception as ex: print("Can NOT delete that Language: ") print(ex)
def getLanguages(self): #SELECT * Query languages = [] q = "SELECT * FROM " + self.__tableName self.__SQL_Connector.getCursor().execute(q) db_languages = self.__SQL_Connector.getCursor().fetchall() for language in db_languages: l = Language(language[0], language[1]) languages.append(l) return languages
def userDeleteLanguage(): idLang = int(input("Type the index to delete: ")) l = Language(idLang, "NONE") return l
def userUpdateLanguage(): idlang = int(input("Type the id to update: ")) newName = input("Type the new language: ") l = Language(idlang,newName) return l
def userCreateLanguage(): newName = input("Type the language: ") l = Language(0,newName) return l
def updateLanguage(self, Language): #UPDATE Query q = "UPDATE " + self.__tableName + " set language = '%s' WHERE id ='%i' " % ( Language.getLanguageName(), Language.getLanguageId()) self.__SQL_Connector.getCursor().execute(q) self.__SQL_Connector.getConection().commit()
def createLanguage(self, Language): #INSERT Query q = "INSERT INTO " + self.__tableName + " (language) VALUES ('%s')" % ( Language.getLanguageName()) self.__SQL_Connector.getCursor().execute(q) self.__SQL_Connector.getConection().commit()