import sys, string, arcpy from arcpy import env import traceback arcpy.env.overwriteOutput = True arcpy.env.workspace = "C:/Temp/My_DB_Connection.odc" tableList = arcpy.ListTables() for table in tableList: print table # <-- WORKS if not arcpy.Exists("C:/Temp/My_DB_Connection.odc/SURVEY.CONTROL"): print "table does NOT exist" else: print "Oracle table exists"
I am having a very similar but subtly different issue: I have an OLE DB connection to an Oracle 11g database using ArcGIS v10 SP2 and python v2.6. I can connect to the database and when I set my arcpy.env.workspace and list the tables, I can see all tables in the entire database. But arcpy.Exists(table) works for some tables and not others. And of course for the one table I'm interested in, it doesn't work. The table I'm interested in is in the schema for the user that the OLE DB connection uses ("survey").
Here's the code:import sys, string, arcpy from arcpy import env import traceback arcpy.env.overwriteOutput = True arcpy.env.workspace = "C:/Temp/My_DB_Connection.odc" tableList = arcpy.ListTables() for table in tableList: print table # <-- WORKS if not arcpy.Exists("C:/Temp/My_DB_Connection.odc/SURVEY.CONTROL"): print "table does NOT exist" else: print "Oracle table exists"
Prints "table does NOT exist".
Also note that when I connect to the DB in ArcCatalog using the same exact connection file, I can see all tables in the DB (not just SURVEY tables, but I do see them all).
Thanks for the reply James.
I don't think it's user permissions since I'm able to select from the problem table in SQLDeveloper. If I view the GRANTS in SQLDeveloper for a problem table and one that I'm able to see in arcpy, there is no difference in the grants. (There actually aren't any at all for either table, but that could be not because they're not there, but because of what my login ID has permission to view).
I just downloaded cx_Oracle and may take the same tack. If you have any code to share, I'd be most grateful.
### create the temporary table gp.createtable_management("IN_MEMORY", "TempDT", "", "") ### Build a DSN (can be subsitited for a TNS name) dsn = cx_Oracle.makedsn("servername", service_name, "database") oradb = cx_Oracle.connect("user", "password", dsn) cursor = oradb.cursor() ### Build the SQL statement and execute it on the cursor object cursor.execute("""SELECT field1, field2 FROM table1 WHERE table1.field1 = somevalue""") ### locate the temporary table we just created and use the results ### of the cursor to contsruct it's structure tables = gp.ListTables() for tbl in tables: if tbl=="TempDT": for i in range(0, len(cursor.description)): val1 = str(cursor.description[0]) val2 = str(cursor.description[1]) val3 = str(cursor.description[2]) if val2=="<type 'cx_Oracle.STRING'>": fldType = "Text" val3 = cursor.description[2] gp.AddField(tbl, str(cursor.description[0]), fldType, val3) if val2=="<type 'cx_Oracle.NATIVE_FLOAT'>": fldType = "Float" gp.AddField(tbl, str(cursor.description[0]), fldType) if val2=="<type 'cx_Oracle.DATETIME'>": fldType = "Date" gp.AddField(tbl, str(cursor.description[0]), fldType) ### populate the in_memory table we just constructed from the cx_Oracle cursor tables = gp.ListTables() for tblNew in tables: if tblNew=="TempDT": ### now populate the table insRows = gp.InsertCursor(tblNew) cxRows = cursor.fetchall() for cxRow in cxRows: insRow = insRows.newRow() for i in range(0, len(cursor.description)): insRow.setvalue(str(cursor.description[0]), cxRow) insRows.insertRow(insRow) cursor.close() oradb.close()
Hey world!
So my scripts have been tried-and-true for years until
https://support.microsoft.com/en-us/kb/3126587
was installed on my production server.
I re-installed Oracle client, I am able to run the script but now at the first line of my script that calls
WCSS_SOURCE = "D:/SpatialAdapters/ArcCatalog/OLE DB ConnectionWCSS.odc/WCSS.DMJOB_EOWR_MV"
try:
print "now let us do the arcpy.exist function call"
if arcpy.Exists(WCSS_SOURCE):
print "Source Table Exists"
now = datetime.datetime.now()
print "Ended: " + str(now) + "\n"
except:
arcpy.AddError("Python Messages: " + arcpy.GetMessages())
I get these messages:
D:\SpatialAdapters\DMJob Attachments>python simple.py
GisBuild of DMJOB_EOWR
Started: 2016-03-21 12:51:30.914000
now let us do the arcpy.exist function call
LoadLibraryFromPath: FQ Dll C:\Windows\system\oci.dll is not found, error: 0x7e
LoadLibraryFromPath: FQ Dll C:\Windows\oci.dll is not found, error: 0x7e
LoadLibraryFromPath: FQ Dll C:\PROGRAM FILES (X86)\ARCGIS\DESKTOP10.2\BIN\oci.dll is not found, error: 0x7e
LoadLibraryFromPath: FQ Dll D:\app\wellsgis-a\product\11.1.0\client_1\BIN\bin\oci.dll found
LoadLibraryFromPath: FQ Dll C:\Windows\system\SQLLib80.dll is not found, error:0x7e
LoadLibraryFromPath: FQ Dll C:\Windows\SQLLib80.dll is not found, error: 0x7e
LoadLibraryFromPath: FQ Dll C:\PROGRAM FILES (X86)\ARCGIS\DESKTOP10.2\BIN\SQLLib80.dll is not found, error: 0x7e
LoadLibraryFromPath: FQ Dll D:\app\wellsgis-a\product\11.1.0\client_1\BIN\bin\SQLLib80.dll is not found, error: 0x7e
LoadLibraryFromPath: FQ Dll C:\Program Files\HP\NCU\SQLLib80.dll is not found, error: 0x7e
LoadLibraryFromPath: FQ Dll C:\Windows\system32\SQLLib80.dll is not found, error: 0x7e
LoadLibraryFromPath: FQ Dll C:\Windows\SQLLib80.dll is not found, error: 0x7e
LoadLibraryFromPath: FQ Dll C:\Windows\System32\Wbem\SQLLib80.dll is not found,error: 0x7e
LoadLibraryFromPath: FQ Dll C:\Windows\System32\WindowsPowerShell\v1.0\SQLLib80.dll is not found, error: 0x7e
LoadLibraryFromPath: FQ Dll C:\Windows\idmu\common\SQLLib80.dll is not found, error: 0x7e
LoadLibraryFromPath: FQ Dll C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\SQLLib80.dll is not found, error: 0x7e
LoadLibraryFromPath: FQ Dll C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\SQLLib80.dll is not found, error: 0x7e
LoadLibraryFromPath: FQ Dll C:\Program Files\Microsoft SQL Server\100\Tools\Binn\SQLLib80.dll is not found, error: 0x7e
LoadLibraryFromPath: FQ Dll C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\SQLLib80.dll is not found, error: 0x7e
LoadLibraryFromPath: FQ Dll C:\Program Files\Microsoft SQL Server\100\DTS\Binn\SQLLib80.dll is not found, error: 0x7e
LoadLibraryFromPath: FQ Dll d:\Python27\ArcGIS10.2\SQLLib80.dll is not found, error: 0x7e
LoadLibraryFromPath: FQ Dll C:\Program Files\HP\HP BTO Software\lib\SQLLib80.dll is not found, error: 0x7e
LoadLibraryFromPath: FQ Dll C:\Program Files\HP\HP BTO Software\bin\SQLLib80.dll is not found, error: 0x7e
LoadLibraryFromPath: FQ Dll C:\Program Files\HP\HP BTO Software\bin\win64\SQLLib80.dll is not found, error: 0x7e
LoadLibraryFromPath: FQ Dll C:\Program Files\HP\HP BTO Software\bin\win64\OpC\SQLLib80.dll is not found, error: 0x7e
LoadLibraryFromPath: FQ Dll C:\Program Files\OmniBack\bin\SQLLib80.dll is not found, error: 0x7e
LoadLibraryFromPath: FQ Dll C:\Program Files\1E\NomadBranch\SQLLib80.dll is notfound, error: 0x7e
Source Table Exists
Ended: 2016-03-21 12:51:37.154000
Are you using a Windows Server 2003 or Windows server 2008 to run this script?
window server 2008 r2 64 bit.
The script has been in place for several years - no issue.
It seems that since that KB was installed and server was restarted, we now see these loadlibrary errors
BUT the script still runs as you can see from the log messages I issue using the python print command.
Plus, the work that needs to get done is being done without issue.
Just do not like to see all these weird msgs
Seems like I see each line for each Path entry in environment variable (not 100% sure though)
Any clues???