Jump to content
Fórum Script Brasil
  • 0

Update no banco de dados Oracle via Python


José Gomes Neto

Question

Qual o código para atualizar uma coluna do banco Oracle com uma variável Python?

 

O código abaixo funcio0na no SQL server, mas no Oracle não !


########### GRAVA O CONTEÚDO DA VARIÁVEL Y_predict0 NA COLUNA Desfecho_Algoritmo_RF na TABELA Tab_PythonTestes_Sem_desfecho ######################
#
df0_GRAVA_DesfechoAlgoritmoRF = x_testRF
#
df0_GRAVA_DesfechoAlgoritmoRF['Desfecho_Algoritmo_RF_TabCom']  = y_predict0
sizes0_new = y_predict0 
#
for index, row in df0_GRAVA_DesfechoAlgoritmoRF.iterrows():
    cursor.execute("UPDATE PythonTestes.dbo.Tab_PythonTestes_Com_desfecho SET Desfecho_Algoritmo_RF_TabCom = (?) WHERE CHAVE_PK is not null AND CHAVE_PK = (?);", row.Desfecho_Algoritmo_RF_TabCom,row.CHAVE_PK) 
    conexao.commit()
#cursor.close()
#
print("                                           ")
print("Dados preditos referentes ao desfecho y, GRAVADOS na tabela Tab_PythonTestes_Com_desfecho")
print("                                           ")
sizes0_new = df0_GRAVA_DesfechoAlgoritmoRF['Desfecho_Algoritmo_RF_TabCom'].value_counts(sort=1) 
print (sizes0_new)
#

###################################################################################################################################

 

Obrigado !!

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.1k
    • Total Posts
      651.9k
×
×
  • Create New...