bartkowalski

Can't view created feature class

Discussion created by bartkowalski on Dec 14, 2011
Latest reply on Jan 3, 2012 by hzhu
Hi,

I've written a script that connects to a SQL Server via pyodbc, and creates a feature class from a table. The code runs fine, but one in Arc, I don't see my feature class, although the attributes are all there. I am new to python, and can't figure out what I am missing.
import arcpy
#reload(arcpy)
import pyodbc
from arcpy import env
cnxn = pyodbc.connect('Driver={SQL Server Native Client 10.0};UID=ID;PWD=Password;SERVER=spk-db11sac.spk.ds.usace.army.mil; DATABASE=ftord; APP=MyApp')

cursor=cnxn.cursor()
cursor.execute("select aquifer, site_id, well_name, station_name, well_type, welltype_desc, northing, easting, coord_source, toc, ground_elev, top_screen_depth, bot_screen_depth, total_depth, diameter, installer, date_inst, date_aban, destroyed, purge_vol, norm_dtw, pump_depth, comments, well_status, destruction_rationale, date_destroyed, ref_document, destruct_permit_number from dbo.Wells_view")
rows = cursor.fetchall()

env.overwriteOutput = True
env.workspace = r"G:\Fort_Ord_GIS\Master_Coverage\Fort_Ord.gdb"
template = r"G:\Fort_Ord_GIS\Master_Coverage\Fort_Ord.gdb\improvement_well\water_well_point"

Wells = arcpy.CreateFeatureclass_management(r"G:\Temp\Bart\scratch.gdb", "ODB11", "POINT",'', "DISABLED", "DISABLED", template)

#arcpy.AddField_management(Wells,'SubTypeIdentifier','TEXT')
arcpy.AddField_management(Wells,'PKWellID','TEXT')  
arcpy.AddField_management(Wells,'PKMApID','TEXT')
arcpy.AddField_management(Wells,'FKMetalID','TEXT')
arcpy.AddField_management(Wells,'FKMediaID','TEXT')
arcpy.AddField_management(Wells,'FKCoordbtID','TEXT')
arcpy.AddField_management(Wells,'FKMnwellID','TEXT')
arcpy.AddField_management(Wells,'WellCatDOM','TEXT')
arcpy.AddField_management(Wells,'WellTypDOM','TEXT')
arcpy.AddField_management(Wells,'WellStaDOM','TEXT')
arcpy.AddField_management(Wells,'CaseMatDOM','TEXT')
arcpy.AddField_management(Wells,'ConstTyDOM','TEXT')
#arcpy.AddField_management(Wells,'HoleDia','TEXT')
arcpy.AddField_management(Wells,'DiaUOM','TEXT')
#arcpy.AddField_management(Wells,'Depthto1st','TEXT')
#arcpy.AddField_management(Wells,'Depthtowat','TEXT')
#arcpy.AddField_management(Wells,'Depthtobdk','TEXT')
#arcpy.AddField_management(Wells,'Totaldepth','TEXT')
#arcpy.AddField_management(Wells,'ReferElev','TEXT')
#arcpy.AddField_management(Wells,'ElevUOM','TEXT')
arcpy.AddField_management(Wells,'DepthUOM','TEXT')
#arcpy.AddField_management(Wells,'Capacity','TEXT')
arcpy.AddField_management(Wells,'CapacUOM','TEXT')
arcpy.AddField_management(Wells,'FKWpumpID','TEXT')
arcpy.AddField_management(Wells,'FKWpumpID','TEXT')
arcpy.AddField_management(Wells,'FKTankID','TEXT')
arcpy.AddField_management(Wells,'FKInstInID','TEXT')
arcpy.AddField_management(Wells,'FKBuildngID','TEXT')
arcpy.AddField_management(Wells,'FKProjectID','TEXT')
arcpy.AddField_management(Wells,'FKStationID','TEXT')
arcpy.AddField_management(Wells,'FKFulzoneID','TEXT')
arcpy.AddField_management(Wells,'FKWatsectID','TEXT')
arcpy.AddField_management(Wells,'FKGaszoneID','TEXT')
arcpy.AddField_management(Wells,'FKHcszoneID','TEXT')
arcpy.AddField_management(Wells,'FKStosectID','TEXT')
arcpy.AddField_management(Wells,'Narrative','TEXT')




Wcur = arcpy.InsertCursor(Wells)

for row in rows:
        #print row.well_name
        t_row = Wcur.newRow()
        t_row.PKWellID = row.well_name
        t_row.WellStaDOM = row.welltype_desc
        Wcur.insertRow(t_row)
#for row in rows:
        #t_row = Wcur.newRow()
        #t_row.PKWellID2 = row.station_name
        #Wcur.insertRow(t_row)

cnxn.commit() 
cursor.close()
cnxn.close()

del row
del rows
del cursor 
del cnxn


Help greatly appreciated in advance.

BArt

Outcomes