I have a SQL query, mad in Python using Psycopg2. The query reads some columns from the arches table:
rows = archesDB.read_all("""SELECT "+str(columns)[1:-1].replace("'","")+"
FROM arches
WHERE lower(arch) like '%%%s%%'""" % (arch.lower()))
I want to parametrize this query, so that it will not specify the columns needed using string concatenation, but as parameters - a far more elegant way.
The naïve way is to SELECT *, and filter out the columns I need. But this burdens the DB and network with unneeded data, so I rather avoid it.
Any ideas?
Adam