I am trying to use SQL in Python to extract data.
It works fine when it is a simple query like:
query="""
SELECT OBJECTID
FROM ACTIVITY
"""
a=cursor.execute(query)
But when I try to put a number in it, then it will have an error:
And the same error also happen when i try LIMIT, ROWNUM etc. It looks like I cannot just put a number in the code like this.
I also tried this way:
But the same error occured.
Also, I tried:
query="""
SELECT TOP %s OBJECTID
FROM ACTIVITY
"""
num = 5
a=cursor.execute(query, num)
But I have got this:
So, i want to know how to transfer integers, floats and strings into sql in Python like parameters?


