Skip to content

Commit

Permalink
Use model_dump_json()
Browse files Browse the repository at this point in the history
  • Loading branch information
pederhan committed Aug 9, 2023
1 parent 4765857 commit f653bc3
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions zabbix_auto_config/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,14 @@ def handle_source_host(
# logging.debug(f"Replaced host <{host['hostname']}> from source <{source}>")
cursor.execute(
f"UPDATE {self.db_source_table} SET data = %s WHERE data->>'hostname' = %s AND data->'sources' ? %s",
[host.json(), host.hostname, source],
[host.model_dump_json(), host.hostname, source],
)
return HostAction.UPDATE
else:
# logging.debug(f"Inserted host <{host['hostname']}> from source <{source}>")
cursor.execute(
f"INSERT INTO {self.db_source_table} (data) VALUES (%s)", [host.json()]
f"INSERT INTO {self.db_source_table} (data) VALUES (%s)",
[host.model_dump_json()],
)
return HostAction.INSERT

Expand Down Expand Up @@ -440,13 +441,14 @@ def handle_host(
# logging.debug(f"Replaced host <{host['hostname']}> from source <{source}>")
cursor.execute(
f"UPDATE {self.db_hosts_table} SET data = %s WHERE data->>'hostname' = %s",
[host.json(), host.hostname],
[host.model_dump_json(), host.hostname],
)
return HostAction.UPDATE
else:
# logging.debug(f"Inserted host <{host['hostname']}> from source <{source}>")
cursor.execute(
f"INSERT INTO {self.db_hosts_table} (data) VALUES (%s)", [host.json()]
f"INSERT INTO {self.db_hosts_table} (data) VALUES (%s)",
[host.model_dump_json()],
)
return HostAction.INSERT

Expand Down

0 comments on commit f653bc3

Please sign in to comment.