I have a script that loads a vector layer from an enterprise geodatabase (PostgreSQL database).

arcpy.MakeFeatureLayer_management(r"M:\SDE\[email protected]/ven.x.y","vlyr")

I have also tried

arcpy.MakeFeatureLayer_management(r"M:\SDE\[email protected]/SDE.ven.x.y","vlyr")

as suggested in How does one access a featurelayer in SDE via Python?

It works on Desktop. The published tool returns the error:

File "\...\hosting-root-directories\arcgissystem\arcgisinput\toolName.GPServer\extracted\p20\services_test\skriptName.py", line 5 g_ESRI_variable_1 = os.path.join(arcpy.env.packageWorkspace,'\\...\hosting-root-directories\arcgissystem\arcgisinput\toolName.GPServer\extracted\p20\[email protected]\SDE.ven.x.y"'') ^ SyntaxError: EOL while scanning string literal

I have registered the database in the Manage Registered Datastores via add -> database -> import. The connection link is


It is the same for publisher and server. I can uncheck "same as publisher", but then I cannot enter anything, as I did for registering the folders (C:).

How do I need to address the file in an EGDB so that it is recognized as being in the registered database? Or do I maybe have to run "Enable Enterprise Geodatabase" (right click on database in catalog pane)? It says that the authorization file is on "\Program Files\ESRI\License<release#>\sysgen folder on Windows". I cannot find this path, does it refer to the server. In the server manager in the browser I could also not find it. Where do I access the sript on the server? I read in some posts here that people did that and just fixed the paths there. Do I have to ask an admin to do it or could I do it as publisher?

When I hover over the database in catalog, it shows up "Type: Enterprise Connection".

When I replace the path to the EGDB with a path to a shapefile, (the folder where the shapefile is in being registered as a datastore), the published tool returns the error:

File "\...\hosting-root-directories\arcgissystem\arcgisinput\toolName.GPServer\extracted\p20\folderName\script.py", line 7 g_ESRI_variable_3 = 'C:\shapefileName.shp'00.shp' ^ SyntaxError: invalid syntax

2 Answers 2


First, and most importantly, do not use Make Feature Layer in a GP Service. There are times when it may make sense, but based on your code snippet, you're just turning a feature class into a layer.

arcpy.MakeFeatureLayer_management(r"M:\SDE\[email protected]/ven.kacheln.dtk100_k40_utm32s","vlyr")

This is an expensive operation. In fact, if it's not the biggest, it's very close to the biggest performance mistake people make in their GP Service. The only time it may make sense to use it would be if you're attaching a where-clause. Even in that situation there would be a better way to achieve your result. See the performance help tip on layers. Since I'm saying don't Make layers, then how do you use a layer? Your workflow starts with a layer. As you're writing a Python script, you just name match the layer in the Contents panel to the variable in your script.

For example, if you have a layer in your Contents panel named vlyr, inside your script you would have:

myLayerVar = "vlyr"
arcpy.Buffer_management(myLayerVar, "10 Kilometers" ....)

There is a screen shot in the Referencing layers as project data section of this help topic that shows this name match.

Obviously the script tool is not portable: it's tightly tied to the Project/Map with that layer inside. (that's fine. You're making a tool designed to be turned into a GP Service) However, when you publish the GP Service, the process will start up the layer and have it ready within the service. No need to Make the layer every time. This blog I wrote a few years is not focused on using layers, but shows it in practice.

If you've made it this far and you've re-designed your script, now to sort out the publishing problem. My two suggestions when publishing:

  1. Make sure the reference data option is selected in the Publishing Tool dialog. (NOT the copy data)
  2. Before publishing / analyzing, clear your data store entry. When you analyze, it should flag and say "this data set will be copied". Use the analyzer to help create your data store entry. Re-analyze and the copy data warning should go away. Publish your tool and no longer worry about .SDE files.
  • thanks! I added the layer as a parameter to the script. So far no error about it, but I cannot be shure it is working, because now it throws "module logger not found" (it is imported in the MDCS script that I call several times). But I hope the actual problem of this post is solved. However, it would of course be nice to be able to access database data in the future. This time the workaround is viable, because there are only three vector layers I need from that data base, but if there would be more data... Commented May 16, 2023 at 19:33
  • Referenced data was selected, and there were no flags in the analyser, otherwise I couldn't have published, right? I do not think the registering was the problem, but the fact that in the script I referred to that file like a normal file in a folder, which of course is not registered. So, the answer is propably something like "SDE_File_Name.NameOfFeatureClass". I might look into it further later, for now I need to get it working anyhow. Commented May 16, 2023 at 19:34

As suggested by @KHibma, I put the feature class in the map content as a layer and introduced it as a parameter of the tool. I can confirm if this works once I solve Use same folder path for publisher and server in Manage registered datastores

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.