I have a list of IDs for which I want to extract other information from a sql table. This is my python 3 code:
ID=['A1','A3','B45','F44']
for i in ID:
sqlquery="select Name, Age from TABLE where id=%s"
cursor.execute(sqlquery,i)
I get this error upon running the code:
vertica_python.errors.Error: Argument 'parameters' must be dict or tuple
1 Answer 1
The argument must be a tuple. Do it like this:
ID=['A1','A3','B45','F44']
for i in ID:
sqlquery="select Name, Age from TABLE where id=%s"
cursor.execute(sqlquery,(i,))
Note: the (i,) treats i as single element tuple
answered Apr 12, 2019 at 14:27
rdas
21.4k6 gold badges39 silver badges48 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-py