I'm creating an API which will allow queries to be performed on my GeoDatabase. I'm using ArcSDESQLExecute to connect to ArcSDE (backed with an Oracle database). Creating the connection object is very slow (~1.5 s):
sde_conn = arcpy.ArcSDESQLExecute(r"data\Connection to GPSERVER3.sde")
So doing this before while handling an API request makes response times very slow.
However, if I create
sde_conn once, for the life of the API, and re-use it indefinitely, queries are much faster (~20ms in some cases), since it's not recreating
sde_conn each time.
Is it bad practice to keep
sde_conn alive? I suspect that creating the object creates a persistent connection. Does anyone know what it's doing under the hood? (is it opening and closing the connection during each call to