コード例 #1
0
    def install_helper(self):
        self.installer_panel = HelperInstallPanel(self._owner, self._main_view.editor, self._ctrl_be)
        self._content.add(self.installer_panel, 1, 2, 2, 3, 0)
        self._owner.relayout() # needed b/c of layout bug in Mac

        if self._ctrl_be.target_version >= Version(5, 7, 10):
            filechooser = FileChooser(mforms.OpenFile)
            filechooser.set_title("Specify the location of mysql_upgrade")
            if filechooser.run_modal():
                self.installer_panel.importer._upgrade_tool_path = filechooser.get_path()

        self.installer_panel.importer.set_password(self._ctrl_be.get_mysql_password())
        self.installer_panel.start()
コード例 #2
0
def exportSQLServer(catalog):

    haveFKeys = 0
    version = grt.root.wb.info.version  #  V.getGlobal("/wb/info/version")
    versionNumber = "%d.%d.%d" % (version.majorNumber, version.minorNumber,
                                  version.releaseNumber)
    print versionNumber
    if validateForSQLServerExport(catalog) != 0:
        return 1

    #-- we don't have requestFileSave in <= 5.1
    #    path = Workbench:requestFileSave("Save as", "SQL Files (*.sql)|*.sql")
    filechooser = FileChooser(mforms.SaveFile)
    filechooser.set_extensions("SQL Files (*.sql)|*.sql", "sql")
    filechooser.set_title("Save Microsoft SQL Server Create File")
    # fileChooser.set_directory(self.logfile_path)
    if filechooser.run_modal():
        path = filechooser.get_path()
    else:
        YesNoBox("Exiting", "Cancel Chosen")
        return 0

    with open(path, "w+") as file:
        #file = io.open(path, "w+")
        if (file == None):
            YesNoBox("Error", "Cannot open file %s" % (path))
            return 1
        #end

        #--  if (not path:find("\.sql$")) then
        #-- truncate db file
        #--    file:close()
        #--    file = io.popen("SQLServer3 -batch -bail " .. path, "w")
        #--  end

        info = grt.root.wb.doc.info
        file.write(
            infoFormat(
                "Creator", "MySQL Workbench %s /ExportSQLServer plugin %s" %
                (versionNumber, ModuleInfo.version)))
        file.write(infoFormat("Author", info.author))
        file.write(infoFormat("Caption", info.caption))
        file.write(infoFormat("Project", info.project))
        file.write(infoFormat("Changed", info.dateChanged))
        file.write(infoFormat("Created", info.dateCreated))
        file.write(infoFormat("Description", info.description))

        #-- loop over all catalogs in schema, find main schema
        #-- main schema is first nonempty schema or nonempty schema named "main"
        iMain = -1
        i = 0
        for schema in catalog.schemata:
            if (len(schema.tables) > 0):
                if (iMain < 0):
                    iMain = i
                #end
                if (schema.name == "dbo"):  # dbo is SQL Server's main schema.
                    iMain = i
                    break
                #end
            #end
            i += 1
        #end

        if (iMain > -1):
            if (exportSchema(file, catalog.schemata[iMain], True) != 0):
                print "Error writing schema %s\n" % (
                    catalog.schemata[iMain].name)
                return 1
            #end
        #end

        i = 0
        for schema in catalog.schemata:
            uniqueId = 1
            if (i != iMain):
                if (exportSchema(file, schema, False) != 0):
                    print "Error writing schema %s\n" % (
                        catalog.schemata[i].name)
                    return 1
                #end
            #end
            i += 1
        #end

    print "Export to %s  finished.\n" % (path)
    return 0
コード例 #3
0
def exportSQLServer(catalog):

    haveFKeys = 0
    version = grt.root.wb.info.version #  V.getGlobal("/wb/info/version")
    versionNumber = "%d.%d.%d" % (version.majorNumber, version.minorNumber, version.releaseNumber)
    print versionNumber
    if validateForSQLServerExport(catalog) != 0:
    	return 1

    #-- we don't have requestFileSave in <= 5.1
    #    path = Workbench:requestFileSave("Save as", "SQL Files (*.sql)|*.sql")
    filechooser = FileChooser(mforms.SaveFile)
    filechooser.set_extensions("SQL Files (*.sql)|*.sql", "sql")
    filechooser.set_title("Save Microsoft SQL Server Create File")
    # fileChooser.set_directory(self.logfile_path)
    if filechooser.run_modal():
        path = filechooser.get_path()
    else:
        YesNoBox("Exiting", "Cancel Chosen")
        return 0

    with open(path, "w+") as file:
        #file = io.open(path, "w+")
        if (file == None):
            YesNoBox("Error", "Cannot open file %s" % (path))
            return 1
        #end
      
        #--  if (not path:find("\.sql$")) then
        #-- truncate db file
        #--    file:close()
        #--    file = io.popen("SQLServer3 -batch -bail " .. path, "w")
        #--  end
      
        info = grt.root.wb.doc.info
        file.write(infoFormat("Creator", "MySQL Workbench %s /ExportSQLServer plugin %s" % (versionNumber, ModuleInfo.version)))
        file.write(infoFormat("Author", info.author))
        file.write(infoFormat("Caption", info.caption))
        file.write(infoFormat("Project", info.project))
        file.write(infoFormat("Changed", info.dateChanged))
        file.write(infoFormat("Created", info.dateCreated))
        file.write(infoFormat("Description", info.description))

        #-- loop over all catalogs in schema, find main schema
        #-- main schema is first nonempty schema or nonempty schema named "main"
        iMain = -1
        i = 0
        for schema in catalog.schemata:
            if (len(schema.tables) > 0):
                if (iMain < 0):
                    iMain = i
                #end
                if (schema.name == "dbo"):  # dbo is SQL Server's main schema.
                    iMain = i
                    break
                #end
            #end
            i += 1
        #end

        if (iMain > -1):
            if (exportSchema(file, catalog.schemata[iMain], True) != 0):
                print "Error writing schema %s\n" % (catalog.schemata[iMain].name)
                return 1
            #end
        #end

        i = 0
        for schema in catalog.schemata:
            uniqueId = 1
            if (i != iMain):
                if (exportSchema(file, schema, False) != 0):
                    print "Error writing schema %s\n" % (catalog.schemata[i].name)
                    return 1
                #end
            #end
            i += 1
        #end

    print "Export to %s  finished.\n" % (path)
    return 0