Select to view content in your preferred language

Python Payload WHERE clause syntax error

557
2
Jump to solution
01-19-2024 07:22 AM
kapalczynski
Regular Contributor

I am creating a data parameter to pass to my Rest Service to Delete a bunch of records.

This works great on my laptop via VPN into my work servers

When a DBA runs this from the server itself I get a syntax error on the WHERE clause... I am very puzzled... wondering if anyone has seen this before... 

Again it runs fine from my computer but its not on the server.... 

 

        whereclause='1=1'
        gis_payload = {
            'token': portaltoken,
            'f': 'json',
            'where': f'''{whereclause}'''
            }
        print(gis_payload)
        response = requests.request("POST", url=url, data=gis_payload)

 

When I print the gis_Payload variable it looks good to me...

 

{'token': 'LRbp-wYEmcO_OFXps89bFEt3HZX34KhpqEAIWJeZE7rgxULrvuAFsSp-cqpkaB74K5ccaDNzjlXuYYCn33cyknr1Vo6', 'f': 'json', 'where': '1=1'}

 

kapalczynski_0-1705677654919.png

0 Kudos
1 Solution

Accepted Solutions
JohannesLindner
MVP Frequent Contributor

Is there any reason to use an f-string here? Does this work?

whereclause='1=1'
gis_payload = {
    'token': portaltoken,
    'f': 'json',
    'where': whereclause
}
print(gis_payload)
response = requests.request("POST", url=url, data=gis_payload)

Have a great day!
Johannes

View solution in original post

0 Kudos
2 Replies
JohannesLindner
MVP Frequent Contributor

Is there any reason to use an f-string here? Does this work?

whereclause='1=1'
gis_payload = {
    'token': portaltoken,
    'f': 'json',
    'where': whereclause
}
print(gis_payload)
response = requests.request("POST", url=url, data=gis_payload)

Have a great day!
Johannes
0 Kudos
kapalczynski
Regular Contributor

I will check... I converted to this before I saw your responce

whereclause="{}".format("1=1")
gis_payload = {
'token': portaltoken,
'f': 'json',
'where': whereclause
}
0 Kudos