Jan-19-2022, 07:50 AM
I have a query. My query returns the result that i want as a dictionary.
Like:
How can i solve this issue?
Thank you for your helps.
Like:
[{'community_string': 'public'}, {'community_string': 'private'}]I want to use only public and private as a string. For doing it, i wrote my code like that:query= "SELECT community_string FROM nat_snmp_string WHERE status ='enable'"
cursor = connection.cursor(dictionary=True)
cursor.execute(query)
com_str = cursor.fetchall()
com_str_string = com_str.values()
cmnyt_str = json.dumps(list(com_str))
print(cmnyt_str)
cmd_line = cmnyt_str.replace(':','')
cmd_line = cmd_line.replace('"','')
cmd_line = cmd_line.replace(']','')
cmd_line = cmd_line.replace('[','')
but it gives me AttributeError: 'list' object has no attribute 'values' error.How can i solve this issue?
Thank you for your helps.
