Я хочу выбрать столбцы по имени, указанному пользователем, но я хочу избежать SQL-инъекций.
Я думаю, что-то подобное не очень хорошая идея:
column_one = input("Column one")
column_two = input("Column two")
column_three = input("Column three")
sql.execute("Select {}, {}, {} from table;".format(column_one, column_two, column_three))
Я могу использовать что-то подобное:
con = sql.connect("example.sqlite3")
select = "select ? from table;"
t = ('id', )
cur = con.cursor()
cur.execute(selec, t)
rows = cur.fetchall()
con.commit()
con.close()
for row in rows:
for cell in row:
print(cell)
Что я получаю: id id id id id id id id ...