Jan-24-2022, 11:51 AM
Thanks for the explanation. I now see the result of:
qry = "INSERT INTO rules (%s) VALUES (%s)" % (qmarks, qmarks)... is:
Output:INSERT INTO rules (?,?,?,?) VALUES (?,?,?,?)
This is wrong. The first qmarks should be column_names so that the result would be:Output:INSERT INTO rules (sudohost,users,hosts,commands) VALUES (?,?,?,?)
Then I see "qvals_stringed" contains:Output:INSERT INTO rules (?,?,?,?) VALUES (?,?,?,?) sudohost,users,hosts,commands,[['aixacodbt']],[[['root']]],[[['ALL']]],[[(['root'], ['ALL'], [{'run_as': ['ALL'], 'tags': None, 'command': 'ALL'}])]]
That is also wrong. It should contain a tuple with four elements like this:Output:('aixacodbt', 'root', 'ALL', "['root'], ['ALL'], [{'run_as': ['ALL'], 'tags': None, 'command': 'ALL'" )
If you got that fixed you should be able to execute:cursor.execute(qry, qvals_stringed)... without error.