How to Get Rid of Quotes in the SQL expression

416
2
03-14-2013 05:03 PM
babakkasraei
New Contributor II
I have some codes in my script like this.

queryList = selectedFids.replace(';', ',')
          
newName = arcpy.AddFieldDelimiters(lyr, "[OBJECTID]")
         
lyr.definitionQuery =  '{0} in ({1})' .format(newName, queryList)



In the second line for AddFieldDElimiters properties I have to use Quotes for [OBJECTID] to work.

In my SQL query I must only use [OBJECTID] without quotes, but quotes come to my query from newName.

I need to get rid of the quotes in the sql query. How can I do that?

Please help me.

Best regards

Babak
Tags (2)
0 Kudos
2 Replies
KerryAlley
Occasional Contributor
Hi Babak,
In the query, try stripping the double quotes:
lyr.definitionQuery =  '{0} in ({1})' .format(newName.strip('"'), queryList)
0 Kudos
babakkasraei
New Contributor II
Hi Babak,
In the query, try stripping the double quotes:
lyr.definitionQuery =  '{0} in ({1})' .format(newName.strip('"'), queryList)


Thank you Kerry

It works.
0 Kudos