In my MySQL database I have 10 tables. Based on the user input, I want to select the rows from one of the table. The user input is an image. I am getting the number of columns and rows of pixels the image has and storing it in a variable.
rows,cols,channels = img.shape
w = int(cols)
h = int(rows)
l = w-10
m = w+10
p = h-10
q = h+10
area = w*h
the mysql tables are created basis the area of the image, and hence, depending on the area, I want to select the values from a specific table.
if (area < 110980):
sql = "select * from adf1 where WIDTH between %s and %s and HEIGHT between %s and %s;",(l,m,p,q)
elif (area < 182520):
sql = "select * from adf2 where WIDTH between %s and %s and HEIGHT between %s and %s;",(l,m,p,q)
else:
sql = "select * from adf10 where WIDTH between %s and %s and HEIGHT between %s and %s;",(l,m,p,q)
cur = mysql.connect().cursor()
cur.execute(sql)
I am getting the following error:
TypeError: cannot concatenate 'str' and 'tuple' objects
However, when I pass on a single query within cur.execute I am able to retrieve the results.
cur.execute("select * from adf10 where WIDTH between %s and %s and HEIGHT between %s and %s;",(l,m,p,q))