This is a two part question. I have a list that will have one item in the list
listA=["12345"]
i want to use the item in this list for my postgres look up. the code looks like this:
cur.execute("SELECT DISTINCT first_name, actor_id FROM actor t WHERE actor_id = 'listA'")
I want to call the number "12345" in my list but postgres gets confused if you dont have ' ' around the number. Even if I leave the ' ' out I still need to have the quotes around the whole statement. How can I get this to work when i need quotes? I think the proper name is nested quotes.
there are other points in time that i want to reference a list but the quote marks always come into play and stop this from happening. other times there will be multiple variable in the list.
ids = [10, 20, 30]
cur.execute("SELECT * FROM data WHERE id = ANY(%s);", (ids,))