Python and MySql
Hello,
Currently I have a database (MySql) with a table called monedas where I have the following fields, simbolo and decimales.
Ae I am connecting to an API that generates a response of type dictionary.
I have saved the dictionary as a list to be able to obtain two values (simbolo and decimales), the code is as follows:
count = 0
all_symbols = [(symbol ["symbol"], symbol ["pricePrecision"]) for symbol in response ["symbols"]]
for symbol in all_symbols:
print (symbol [0], symbol [1])
count + = 1
symbol = symbol [0]
decimal = symbol [1]
In this case, I can obtain the two values correctly, but I cannot insert the new values that are different from the ones I have in the currencies table using the following code:
mycursor.execute("INSERT INTO monedap (simbolo, decimales) SELECT 'simbolo', decimales FROM monedas WHERE simbolo = %s and decimales = %s AND NOT EXISTS (SELECT * FROM monedas WHERE simbolo= ' ')", (simbolo, decimal))
Can someone suggest me what to do please.
Regards,
Orlando Gautier
Subject
Written By
Posted
Python and MySql
May 19, 2021 03:31PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.