I have created an SDE database in which I have copied feature classes from my production database from State Plane into WGS 84 for web mapping applications. The final step is to create views, and I am trying to automate the process as I have hundreds of feature classes.
Below, I am trying to make a list of all the feature classes and use the name of the feature class. The middle parameter starts with a prefix of v_ then grabs the feature class name (ie: v_watermeters). The third variable is the SQL statement used to create the view definition, where it grabs all the fields (SELECT * FROM ) then I want to use the feature class name (ie: SELECT * FROM watermeters).
I am having trouble with the third variable and concatenating the string values to make valid code.
We are currently on ArcGIS 10.3.1 and SQL Server 2012.
import arcpy
import os
arcpy.env.workspace = "Database Connections\\Server Database sde.sde"
featureclasses = arcpy.ListFeatureClasses()
for fc in featureclasses:
arcpy.arcpy.CreateDatabaseView_management(
fc, os.path.join("Database Connections\\Server Database sde.sde","v_"+str(featureclasses), "select * from "+featureclasses)
Solved! Go to Solution.
Thank you, that one worked after removing the double 'arcpy'.