1

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:

  • Change the query, just to see if the connection is alright. When I did that (I used 'SELECT info from table'), the script worked.
  • I thought that my query was wrong, but when I execute it in SQLDeveloper program, it goes right.

What can be happening?

Thanks

1
  • First, have you checked if you get any exceptions? Commented Mar 18, 2011 at 11:21

2 Answers 2

2

You are forgetting to call commit.

Sign up to request clarification or add additional context in comments.

1 Comment

The script stops in the con.execute line.
1

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()

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.