Provide credentials for Oracle database when opening MXD file?

المشرف العام

Administrator
طاقم الإدارة
I need to open a MXD file from a Python toolbox (so that I can automatically export it to a PDF). The file contains a connection to an Oracle 11g database, and I need to somehow provide the credentials to the database. None of the methods I have tried so far have worked - the PDF always comes out without any of the data from the database. How can I tell ArcGIS what username and password to use?

Attempt 1: Reference a SDE file:

arcpy.env.workspace = "credentials.sde"mxd = arcpy.mapping.MapDocument(mxd_file)arcpy.mapping.ExportToPDF(mxd, pdf_file)Attempt 2: Create a SDE file:

arcpy.CreateArcSDEConnectionFile_management ( out_folder_path = "C:\\Path", out_name = "temp.sde", server = "prod.world", service = "prod.world", account_authentication = "DATABASE_AUTH", username = "dga", password = "dgal0sen", save_username_password = "SAVE_USERNAME")mxd = arcpy.mapping.MapDocument(mxd_file)arcpy.mapping.ExportToPDF(mxd, pdf_file)I am unsure of what I should use for the parameters server and service? When I look at the connection properties of an SDE file created from ArcCatalog it doesn't have those options. Instead it has the single option "Instance" with the value "sde:eek:racle11g:prod.world", and "Oracle" selected in the "Database platform" dropdown instead of "Application Server".

Attempt 3: Somehow make the MXD remember the username and password. Unsure of how to do that, though.



أكثر...
 
أعلى