SaltStack: MySQL returner save less data into Database table columns - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: SaltStack: MySQL returner save less data into Database table columns (/thread-34158.html) |
SaltStack: MySQL returner save less data into Database table columns - xtc14 - Jul-01-2021 I'm trying to modify the existing SaltStack MySQL returner to only save a handful of data instead of the default columns (| fun | jid | return | id | success | full_ret) to something like(| fun | jid | return | id | success) The file I'm working on is this one: https://github.com/saltstack/salt/blob/master/salt/returners/mysql.py I installed this python module python3-mysqldb so Salt can communicate with MySQL v8.0.25The part that I modified (line 313) try: with _get_serv(ret, commit=True) as cur: sql = """INSERT INTO `salt_returns` (`fun`, `jid`, `id`, `success`) VALUES (%s, %s, %s, %s)"""But I'm getting this error when running something like salt '*' test.ping --return mysql I'm guessing it comes down to how each column in the table was defined, but I'm not sure where to make further modifications to write data in only those columns.
RE: SaltStack: MySQL returner save less data into Database table columns - ibreeden - Jul-02-2021 First we are not fond of providing code as a link. We are a bit scared of where a link brings us. Second: when you delete "full_ret" from the query, you should also remove it from the tuple. So delete line 327. salt.utils.json.dumps(ret), RE: SaltStack: MySQL returner save less data into Database table columns - xtc14 - Jul-02-2021 (Jul-02-2021, 11:32 AM)ibreeden Wrote: First we are not fond of providing code as a link. We are a bit scared of where a link brings us. Thanks! That was what I needed, also had to modify the column to be able to accept NULL values. Appreciated |