#нерабочий код
result = cur.execute('SELECT ? FROM messages ORDER BY id DESC LIMIT 1', (value,)).fetchone() #value = 'message_time '
#рабочий код
result = cur.execute('SELECT message_time FROM messages ORDER BY id DESC LIMIT 1').fetchone()
result = cur.execute(f'SELECT {value} FROM messages ORDER BY id DESC LIMIT 1').fetchone()