|
POST
|
I have a Python script that exports sde attachments, photos submitted through Survey123. I need to rename the resulting JPGs with the site, room and time they were taken. The initial file name only has the relative global ID from the attachment table that relates to the global ID of the room feature in the survey table. Comparing these is how I get the room data for renaming the JPG file. It works just fine, but we have nearly 15,000 rooms over 100 sites, so I want to speed up the cursor search with a SQL query. The problem is, the Global ID field from the survey table is a GUID type field. The identical relative global ID field in the attachment table is a string. The Global ID field is only cast to string inside the cursor GUID = item[0]. The SQL where clause is defined outside the cursor, where Global ID refers to the GUID type field. I've tried converting the relative ID string field to a UUID type, but this hasn't worked. I tried setting the where clause as an empty string and then defining it inside the search cursor loop. I keep getting this error: for item in cursor: RuntimeError: Underlying DBMS error [[Microsoft][ODBC Driver 13 for SQL Server]Syntax error, permission violation, or other nonspecific error] [PPSTest.DBO.CustodianInspection] Here is the relative section of my script: ##Step 2 -Loop through each photo and get time taken from metadata
for jpg in os.listdir(temp_dir):
filepath = temp_dir + "//" + jpg
date_time = (get_date_taken(filepath))
date_time_obj = datetime.datetime.strptime(date_time, '%Y:%m:%d %H:%M:%S')
date_string = date_time_obj.strftime("%b %d %Y")
time_string = date_time_obj.strftime("%I_%M_%S%p")
REL_GUID = jpg[5:43]
##Step 3 -Compare REL_GUID in photo filename to GUID in custodian inspection table to grab site name and room number
where_clause = "WHERE GlobalID = " + REL_GUID
with da.SearchCursor(inspection_table, ['GlobalID', 'SiteName', 'RoomNumber','Comments','appa_score'],where_clause) as cursor:
for item in cursor:
GUID = item[0]
SiteName = item[1]
RoomNum = item[2]
comments = item[3]
appaScore = str(item[4])
... View more
03-04-2021
11:08 AM
|
0
|
2
|
3613
|
|
POST
|
Revisiting this issue. I'm following the docs, but it's not working. I run these lines at the end of my script, but the service still says "The Item is not shared" in the portal. portal = GIS("https://<ourserver>/arcgis", "user", "password")
locator = portal.content.get('<itemID>')
locator.update(item_properties={"access" : "public"})
... View more
03-02-2021
10:04 AM
|
0
|
0
|
4284
|
|
POST
|
Ah, thank you. I realized I need to relate the attachment table not to the feature class, but the survey form that is related to the feature. That's where the attachment REL_GLOBALID matches the survey global ID.
... View more
02-25-2021
08:31 AM
|
2
|
0
|
2799
|
|
POST
|
We have a Field Maps app that shows floor plans at our sites. Custodians click on the room they are in and launch a Survey123 survey. The room data (space ID, room number, room type, etc) are passed to S123 in a custom URL. The problem we're having is that photo attachments don't contain any attributes that tie them to the room they are coming from. There is a REL_GLOBALID field in the attachment table but it doesn't match the Global ID of the room feature. Is there a way to pass the room's space ID to the attachment so we can batch export them and know what room they are associated with?
... View more
02-24-2021
01:50 PM
|
1
|
2
|
2830
|
|
POST
|
Thanks. Would my item be the service ID? I tried service name, but it won't accept a string.
... View more
02-05-2021
01:32 PM
|
0
|
2
|
4337
|
|
POST
|
I have a script that updates geocoders every month and publishes them to our enterprise portal. When this happens I have to manually change the sharing settings to "everyone" for it to be accessible in our public school finder. If I forget to to do this, I get emails saying that the app is asking users to log into the portal. Is there a way to set the sharing settings for a service in Python?
... View more
02-04-2021
09:19 AM
|
0
|
13
|
5390
|
|
POST
|
They just released a patch yesterday and these issues weren't addressed. I can't export PDFs with graphics, or export multiple pdfs with page numbers as filenames.
... View more
02-04-2021
09:15 AM
|
0
|
0
|
1912
|
|
POST
|
Finally figured this out. I'm updating two nearly identical datasets, one for the web and one in local projection for printed maps. The local dataset lacks a Global ID field, so the indexs were off by one and the script was trying to put a date in a non-date field. It's strange that this hasn't been an issue before.
... View more
02-02-2021
10:01 AM
|
0
|
0
|
6745
|
|
POST
|
So even weirder, the script is actually updating the feature with the current datetime, but I'm still getting that error before the script finishes running: Here is my script: import requests
import json
import os, sys
import arcpy
import datetime
##This script checks Tririga for modifications to spaces/rooms in the last week.
##If modifications are found, space attributes are updated in the
##Rooms with Space ID sde feature class.
datetime = datetime.datetime.now()
##Query Tririga for spaces with recent modifications
tririga_mods_url = "https://<tririgaserver>/oslc/spq/PPSspaceModQC?oslc.select=*"
payload = {'USERNAME': 'user', 'PASSWORD': 'password'}
request = requests.get(tririga_mods_url,params=payload)
result = json.loads(request.text)
##print(json.dumps(result, indent=2)) ##prettify json
##sys.exit()
jsonData = result["rdfs:member"]
triSystemID_List = ['10423582',]
##Append Tririga System IDs to empty list
for entry in jsonData:
triSystemID = entry['spi:identifier']
triSystemID_List.append(triSystemID)
##print(triSystemID_List)
##sys.exit()
if len(triSystemID_List) == 0:
print("No recent space modifications")
sys.exit()
else:
##Query Tririga for modifications in each space
for SystemID in triSystemID_List:
tririga_space_query_url = "https://<tririgaserver>/oslc/so/PPSspaceGIS/" + SystemID
request = requests.get(tririga_space_query_url,params=payload)
result = json.loads(request.text)
##Tririga attributes from result dict:
triSpaceClass = result["spi:triCurrentSpaceClass-triNameTX"]
triSpaceClassDesc = result["spi:triCurrentSpaceClass-triDescriptionTX"]
triSpaceID = result["spi:triIdTX"]
triCapacity = result["spi:triDefaultCapacityNU"]
triParentFloor = result["spi:triParentFloorTX"]
triParentBuilding = result["spi:triParentBuildingTX"]
triUsedForK2 = result["spi:cstCurrentlyUsedForK2BL"]
triParentProperty = result["spi:triParentPropertyTX"]
triArea = result["spi:triAreaNU"]
triMeetsK2Criteria = result["spi:cstMeetsCriteriaForK2CommonBL"]
if triMeetsK2Criteria == 1:
triK2Compliant = 'TRUE'
elif triMeetsK2Criteria == 0:
triK2Compliant = 'FALSE'
else:
triK2Compliant = None
triAltSpaceUse = result["spi:cstAlternativeSpaceUseCL"]
triRoomNum = result["spi:triNameTX"]
triParentID = result["spi:triParentIdSY"]
triSystemID = result["spi:identifier"]
##connect to sync enabled sde feature class on ArcGIS server
arcpy.env.workspace = r"C:\Connections\PPS_Enterprise_Prod.sde"
arcpy.env.overwriteOutput = True
rooms_web = "PPSProd.DBO.Rooms_w_SpaceID_All_Sites_WEB"
rooms_harn = "PPSProd.DBO.Rooms_w_SpaceID_All_Sites"
rooms_list = [rooms_web,rooms_harn]
##Only find spaces in the feature class that match the Tririga SpaceID field.
where_clause = "WHERE SpaceID = '" + triSpaceID + "'"
for fc in rooms_list:
with arcpy.da.UpdateCursor(fc, '*', where_clause) as cursor:
##sde feature class attributes 'fc'
for row in cursor:
fcSpaceID = row[2]
fcSiteName = row[5]
fcRoomNum = row[6]
fcK2Compliant = row[7]
fcSpaceClass = row[8]
fcArea = row[9]
fcEditUser = row[13] ## last_edited_user field
fcEditDate = row[14] ## last_edited_date field
fcRoomDescription = row[16]
fcAlternateUse = row[17]
##fcCapacity = row[18]
##update feature class with attrubute data from Tririga 'tri'
if (row[:20] != [triRoomNum,triSpaceClass,triArea,
triK2Compliant, ##triCapacity,
triAltSpaceUse,triSpaceClassDesc]):
row[6] = triRoomNum
row[7] = triK2Compliant
row[8] = triSpaceClass
if fcArea - triArea > 1.0 or fcArea - triArea <= -1.0 :
row[9] = triArea
else:
row[9] != triArea
row[13] = "GIS Admin"
row[14] = datetime
row[15] = triSpaceClassDesc
row[16] = triAltSpaceUse
##row[18] = triCapacity
print("Updating " + triParentProperty + " Room Number " + triRoomNum + " in " + fc)
cursor.updateRow(row)
... View more
02-01-2021
11:08 AM
|
0
|
0
|
2004
|
|
POST
|
Yes, the PDF export issues have gotten worse at 2.7. They were supposed to be addressed at this release. I can output a JPEG just fine, but the PDF drops graphics and replaces them with a lowercase b. And the PDF export options are still screwed up. Can this be addressed soon?
... View more
01-31-2021
06:49 PM
|
0
|
0
|
1937
|
|
POST
|
As far as the sde database management, I’m doing it all in Pro. We’re on enterprise 10.7.1.
... View more
01-28-2021
03:19 PM
|
0
|
7
|
4841
|
|
POST
|
Still trying to figure this out. I've been manually overwriting the hosted feature service when there are changes to the sde data. We discovered today that all the records generated in the related table through Survey123 have been deleted, going back a week and a half. I've tried publishing this data every which way and it's never a referenced data set, just a copy. The sde it comes from is registered with the Portal, so I don't understand what's missing.
... View more
01-28-2021
02:06 PM
|
0
|
0
|
1359
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 12-04-2025 04:06 PM | |
| 1 | 11-24-2025 03:59 PM | |
| 1 | 09-13-2024 10:43 AM | |
| 1 | 06-05-2025 01:26 PM | |
| 3 | 04-04-2025 10:54 AM |
| Online Status |
Offline
|
| Date Last Visited |
12-08-2025
03:20 PM
|