def createDB(database):
    dao.setConnectionParams("root", "rootroot", "3306", database, "localhost",
                            "5.3")
    dao.createDB("dayzitems5")
    dao.loadDB(
        windows.getContent(abspath(join(getcwd(), "..", "data",
                                        "GENESIS.sql"))))
Exemple #2
0
 def createDatabase(self):
     try:
         dao.createDB(self.database.get())
         dao.loadDB(windows.getContent(windows.dataPath + "\\GENESIS.sql"))
     except Exception as e:
         windows.showError(self.window, "Error",
                           "Failed to connect:\n" + str(e))
         windows.deleteParams()
Exemple #3
0
 def loadDB(self):
     self.clearModMenu()
     fname = windows.openFile("sql")
     if fname != "":
         dbName = dao.dropDB()
         dao.createDB(dbName)
         dao.loadDB(getContent(fname))
     try:
         self.fillModMenu()
     except Exception:
         sleep(0.4)
def upgrade():
    lines = dao.backupDatabase().decode("utf-8")
    dbName = dao.dropDB()
    dao.createDB(dbName)
    lines = lines.split("\n")

    for i in range(len(lines)):
        if "CONSTRAINT `itemcombos_ibfk_1`" in lines[i]:
            print("yay")
            lines[i] = "CONSTRAINT `itemcombos_ibfk_3` FOREIGN KEY (`item1`) REFERENCES `items` (`name`) ON DELETE CASCADE,\r"
        elif "CONSTRAINT `itemcombos_ibfk_2`" in lines[i]:
            lines[i] = "CONSTRAINT `itemcombos_ibfk_4` FOREIGN KEY (`item2`) REFERENCES `items` (`name`) ON DELETE CASCADE\r"

    newLines = ""
    for line in lines:
        newLines += line + "\n"

    dao.loadDB("".join(newLines).encode('utf-8'))