2

I came across this problem when tring to access some layers in the enterprise database (Oracle). The codes are written as:

cwd = sys.path[0]

# Process: Create Database Connection
DBConnFile_Name = "Enterprise.sde"
DBConnFile = os.path.join(cwd, DBConnFile_Name)

arcpy.CreateDatabaseConnection_management(
    cwd,
    DBConnFile_Name,
    "ORACLE",
    "<instance name here>",
    "DATABASE_AUTH",
    "<username here>",
    "<password here>",
    "SAVE_USERNAME",
    "",
    "SDE",
    "TRANSACTIONAL",
    "SDE.DEFAULT",
    ""
)

# Get the enterprise database layers
in_Council_Pg = os.path.join(DBConnFile, "DISTRICT_COUNCIL")
in_CrimePrev_Pg = os.path.join(DBConnFile, "DISTRICT_CRIME_PREVENT")
in_ZIP_Pg = os.path.join(DBConnFile, "ZIP")
in_Neighborhood_Pg = os.path.join(DBConnFile, "NEIGHBORHOOD")

I want to use those layers in enterprise database for further processing using other ArcPy functions. When I use the layers saved at local directory as arguments, the entire program runs perfectly fine. But when I try to use the layers in SDE as arguments, Windows tells me that "pythonw.exe has stopped working". One of the functions is written as:

# Process: Spatial Join - Council Districts
arcpy.SpatialJoin_analysis(
    CrimeIncid_Pt_WGS,
    in_Council_Pg,
    CrimeIncid_Pt_Council,
    "JOIN_ONE_TO_ONE",
    "KEEP_ALL",
    "",
    "WITHIN",
    "",
    ""
)

print "Stops here."

The programs fails at the function before printing "Stops here".

Do anybody have similar issue?

closed as off-topic by PolyGeo Jun 24 '17 at 4:24

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This problem cannot or can no longer be reproduced. Changes to the system or to the asker's circumstances may have rendered the question obsolete, or the question does not include a procedure to enable potential answerers to reproduce the same symptoms. Such questions are off-topic as they are unlikely to help future readers, but editing them to include more details can lead to re-opening." – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Are you sure it's failing on one of those 4 lines at the end? Or is it after that? Those 4 lines aren't actually doing anything (there's no connection to any files), it's just constructing a path variable. Try putting those lines before the arcpy.CreateDatabaseConnection_management() and see if/where it fails again – Midavalo Mar 17 '17 at 16:06
  • Thank you for replying, @Midavalo. I tried, but it still fails. There're functions afterwards use the path variables as arguments. – PacmanKX Mar 17 '17 at 16:18
  • Where does it fail? Try adding print statements after the 4 lines, eg print in_Neighborhood_pg etc. to show that they've created paths. Or is it failing at the next functions? – Midavalo Mar 17 '17 at 16:20
  • I inserted print statement at multiple places and it fails at the first function uses one of those 4 variables as argument. The function is written as: 'arcpy.SpatialJoin_analysis(<input point layer>, in_Council_Pg, <output point layer>, "JOIN_ONE_TO_ONE", "KEEP_ALL", "", "WITHIN", "", "")' – PacmanKX Mar 17 '17 at 16:29
  • Can you confirm that it passes the print statements and fails on the next function? Please include that function in your code snippet as the issue may be related to that function – Midavalo Mar 17 '17 at 16:42