AnsweredAssumed Answered

Using STR function in Arcpy Statement

Question asked by brianmcleer on Jan 31, 2019
Latest reply on Feb 4, 2019 by brianmcleer

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:
fc, os.path.join("Database Connections\\Server Database sde.sde","v_"+str(featureclasses), "select * from "+featureclasses)