Frias
Frias

Reputation: 11291

Why my sql doesn't execute?

I have a python script that needs to update a database information. So, in my init() method, I start the connection. But when I call the update method, the script does not give me any answer, it seems like it is into an infinite loop.

def update(self,id,newDescription):
     try:
         sql="""UPDATE table SET table.new_string=:1 WHERE table.id=:2"""                                                                               
         con=self.connection.cursor()
         con.execute(sql,(newDescription,id))
         con.close()
     except Exception,e:
         self.errors+=[str(e)]

What I've tried so far:

What can be happening?

Thanks

Upvotes: 1

Views: 140

Answers (2)

dsmoljanovic
dsmoljanovic

Reputation: 123

Not sure about how to do it in python script, but i think you need to call a "commit" before closing connection. Otherwise oracle rollsback your transaction.

Try adding con.commit() before close()

Upvotes: 1

Klaus Byskov Pedersen
Klaus Byskov Pedersen

Reputation: 120997

You are forgetting to call commit.

Upvotes: 2

Related Questions