Going through the column names in SQLite and executing a command for each column name

I am trying to execute the following command

UPDATE the attachments SET colname = TRIM (colname);

in each column name in a SQLite table.

I found the following approach to get a list of column names in
an answer to "How to get a list of column names in sqlite3 / iPhone?", namely

SELECT the name FROM PRAGMA_TABLE_INFO (& # 39; your_table_ & # 39;);

What seems like a nice, clean and simple way to do it. But this method is specific to SQLite, according to the PRAGMA statements.

In any case, I would like a solution that runs completely in SQLite. Actually I'm calling SQLite from Lua, using LuaSQL. So I could run the loop in Lua if necessary. But doing it inside SQLite just seems cleaner.

It would be even better if it is a general method that works for any RDBMS. But that might not be possible, and if it were, it would probably be more complicated.