I'm trying to access a database located on a remote server.
I used ArcMap "Create Database Connection" tool on my computer to create a SDE file and I want to use a script to add some data to a table located on this remote database.
On the server SQLEXPRESS
there is a database called WeatherData (the SDE file is used to access this database)
and in this database there is a table called Weather1.
I'm currently using this script :
import os
import arcpy
from arcpy import env
directory = os.path.dirname(os.path.realpath(__file__))
arcpy.env.workspace = os.path.join(directory, "SqlServerConnect_UserAuthentication.sde")
table = "Weather1"
tableLocation = os.path.join(arcpy.env.workspace, table)
print arcpy.env.workspace
print tableLocation
print arcpy.ListTables()
arcpy.env.workspace and tableLocation are printed correctly, but arcpy.ListTables() print an empty list
C:\Users\...\ArcGISApp\SqlServerConnect_UserAuthentication.sde
C:\Users\...\ArcGISApp\SqlServerConnect_UserAuthentication.sde\Weather1
[]
which I guess means the script didn't find anything in the workspace. (or couldn't connect to it)
Afterwards, I just want to add some data to the table using another arcpy function
data = os.path.join(directory, "test.csv")
arcpy.Append_management (data, tableLocation, "NO_TEST")
Of course I get an error : (translated from french)
Traceback (most recent call last):
File "C:\Users\...\ArcGISApp\test.py", line 28, in <module>
arcpy.Append_management (data, tableLocation, "NO_TEST")
File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\management.py", line 3785, in Append
raise e
arcgisscripting.ExecuteError: Execution Error. Incorrect parameters
ERROR 000732: Dataset C:\Users\...\ArcGISApp\SqlServerConnect_UserAuthentication.sde
does not exist or is not supported
Execution Error(Append).
So how I am I supposed to use the SDE file to access the database (and the table) correctly ?