def execute(self, environment): result = jsonMode.createDatabase(self.name) """ 0: insert 1: error 2: exists """ if self.mode == None: self.mode = 1 if result == 0: Struct.createDatabase(self.name, self.mode, self.owner) report = "Base de datos insertada" elif result == 1: sintaxPostgreSQL.insert(len(sintaxPostgreSQL), "Error: XX000: Error interno") report = "Error al insertar la base de datos" elif result == 2 and self.replace: Struct.replaceDatabase(self.name, self.mode, self.owner) report = "Base de datos reemplazada" elif result == 2 and self.exists: report = "Base de datos no insertada, la base de datos ya existe" else: report = "Error: La base de datos ya existe" sintaxPostgreSQL.insert(len(sintaxPostgreSQL), "Error: 42P04: base de datos duplicada") return report
def execute(self, environment): result = jsonMode.createDatabase(self.name) """ 0: insert 1: error 2: exists """ if self.mode == None: self.mode = 1 if result == 0: Struct.createDatabase(self.name, self.mode, self.owner) report = "Base de datos: " + self.name + " insertada." elif result == 1: instruction.syntaxPostgreSQL.append("Error: XX000: Error interno") report = "Error al insertar la base de datos: " + self.name elif result == 2 and self.replace: Struct.replaceDatabase(self.name, self.mode, self.owner) report = "Base de datos '" + self.name + " ' reemplazada." elif result == 2 and self.exists: report = "Base de datos no insertada, " + self.name + " ya existe." else: instruction.semanticErrors.append( ["La base de datos " + str(self.name) + " ya existe", self.row] ) instruction.syntaxPostgreSQL.append( "Error: 42P04: La base de datos " + str(self.name) + " ya existe" ) report = "Error: La base de datos ya existe" return report
def execute(self, environment): result = jsonMode.createDatabase(self.name) """ 0: insert 1: error 2: exists """ if self.mode == None: self.mode = 1 if result == 0: Struct.createDatabase(self.name, self.mode, self.owner) report = "Base de datos insertada" elif result == 1: report = "Error al insertar la base de datos" elif result == 2 and self.replace: Struct.replaceDatabase(self.name, self.mode, self.owner) report = "Base de datos reemplazada" elif result == 2 and self.exists: report = "Base de datos no insertada, la base de datos ya existe" else: report = "Error: La base de datos ya existe" return report
def replaceDatabase(name, mode, owner): dropDatabase(name) jsonMode.dropDatabase(name) createDatabase(name, mode, owner) jsonMode.createDatabase(name)