I am using ArcMap 10.3 have a my data in a geodatabase (MS SQL Server Express) and I am trying to write a python script that does a bunch of spatial and non-spatial data manipulation.
I need to dump results into non-spatial tables in MS SQL Server so I can run queries off of them.
However, I cannot seem to get my CREATE table query to run properly. I have tried a bunch of variations of this query (e.g. putting dbo. etc) to no avail.
import arcpy
import os
# Set environment variables for pymssql
import pymssql
server = os.getenv("DRAKE\SQLEXPRESS")
conn = pymssql.connect(server="DRAKE\SQLEXPRESS",database="NATA_Data")
cursor = conn.cursor()
cursor.execute('CREATE TABLE tempIntersect_withNATA (ZIP varchar(max), Measure varchar(max), HAP varchar(max), Result decimal(35,30))')
conn.close()
Nothing seems to happen, even when I paste it into the ArcMap python window. I have created a simple query such as cursor.execute('SELECT * FROM NATA_All')
and that does hook to my database and retrieve data.
import arcpy
but do not use it. I think you should research/ask questions aboutpymssql
at Database Administrators. – PolyGeo♦ Mar 27 at 22:35import arcpy
) works from IDLE (or another IDE). If it does, then can you tell us the error thrown by the Python window of ArcMap when you run that code there, please? – PolyGeo♦ Mar 27 at 23:33