Hello - I have monitoring locations in a SQL Server database. I am creating a hosted feature layer by querying data and Python APIs using the process below-
cnxn_str = ("Driver={SQL Server Native Client 11.0};"
"Server=xyz;"
"Database=xyz;"
"UID=xyz;"
"PWD=xyz;")
cnxn = pyodbc.connect(cnxn_str)
Locationquery = """SELECT [X],[CollectionLatitude],[CollectionLongitude] FROM xyz"""
Locations = pd.read_sql(Locationquery, cnxn)
Locations['SHAPE'] = '"spatialReference": {"wkid": 4326}, {"x":' + Locations['CollectionLongitude'].astype('str') + ', "y":' + Locations['CollectionLatitude'].astype('str') + '}'
sdf=GeoAccessor.from_xy(Locations,'CollectionLongitude','CollectionLatitude')
lyr1 = sdf.spatial.to_featurelayer("MonitoringLocations")Every week, some locations are updated in the database and I would like to update the features in the hosted feature layer using Python APIs. The truncate() option lets me delete all features but I want to overwrite/delete only the features that are updated in the database. Here is how I am pulling the updated locations-
UpdatedLocationQuery = """SELECT [X],[CollectionLatitude],[CollectionLongitude] FROM xyz WHERE LastUpdated >= DATEADD(day, -7, GETDATE())
UpdatedLocations = pd.read_sql(UpdatedLocationQuery, cnxn)
How can I selectively update features in the hosted feature layer? Any help is greatly appreciated.
Thank You.