Hi,
I have a custom toolbox which I added a python script too. The script currently runs when the input parameters are not multivalue, but the script falls over when I set the input parameters to multivalue. Where they seem to be falling over is when I try to use pyodbc to connect to an access database. I am currently using the arcpy.GetParameterAsText function and then using the split function to separate the semicolon delimited string into a list.
This is the error information that I am currently receiving.
Error Info:
<class 'pyodbc.Error'>: ('HY000', "[HY000] [Microsoft][ODBC Microsoft Access Driver] Not a valid file name. (-1044) (SQLDriverConnect); [01000] [Microsoft][ODBC Microsoft Access Driver]General Warning Unable to open registry key 'Temporary (volatile) Jet DSN for process 0x1200 Thread 0x128c DBC 0x24d28a4 Jet'. (1); [01000] [Microsoft][ODBC Microsoft Access Driver]General Warning Unable to open registry key 'Temporary (volatile) Jet DSN for process 0x1200 Thread 0x128c DBC 0x24d28a4 Jet'. (1); [HY000] [Microsoft][ODBC Microsoft Access Driver] Not a valid file name. (-1044)")
A snippet of my code:
import arcpy
import pyodbc
import sys
import os
import pythonaddins
SAGIS_Input = arcpy.GetParameterAsText(0)
SAGIS_model_new = SAGIS_Input.split(";")
SAGIS_Count = len(SAGIS_model_new)
arcpy.AddMessage(SAGIS_Count)
for model in SAGIS_model_new:
SAGIS_model = str(model)
arcpy.AddMessage(SAGIS_model)
# connection to SAGIS model geodatabase
access_conn = pyodbc.connect('DRIVER={Microsoft Access Driver (*.mdb)};DBQ='+SAGIS_model)
access_cursor = access_conn.cursor()
tablelist = arcpy.ListTables()
tablecount = len(tablelist)
arcpy.AddMessage(tablecount)
arcpy.AddMessage("Script run successfully.")
#print "Script run successful."
access_cursor.close()
access_conn.close()I would very much appreciate any advise on how to get the muiltvalue paramters to work with the pyodbc connection.
Thanks in advance.
Ben.