Mar-09-2022, 11:27 AM
have commands like:
SELECT UserName FROM Win32_ComputerSystem
which gives me the username of computer. or SELECT Manufacturer, Model FROM Win32_ComputerSystem it gives me the manufacturer.
In this part of my code
How can i do it? Im so confused because in my for loop I run all the commands in order.
SELECT UserName FROM Win32_ComputerSystem
which gives me the username of computer. or SELECT Manufacturer, Model FROM Win32_ComputerSystem it gives me the manufacturer.
In this part of my code
query = f"select command_line from wmic_commands where id = '{wmic_id}'" cursor = connection.cursor(dictionary=True) cursor.execute(query) command_line = cursor.fetchall() [b] for data in command_line: cmd_line = data['command_line'] output = wmic.query(cmd_line)[/b] result = json.dumps(output) mySql_insert_query = """INSERT INTO wmi_inventory (wmi_data, date) VALUES (%s, %s) """ now = datetime.now() dt_string = now.strftime("%Y-%m-%d-%H:%M:%S") record = (result, dt_string) cursor.execute(mySql_insert_query, record) connection.commit()I execute all these queries in my for loop. And save the output as a json data in my database. But i want to save outputs in to the database like when i execute the username commands, save it in to username column.
How can i do it? Im so confused because in my for loop I run all the commands in order.