On Fri, Jul 10, 2009 at 12:51 PM, Emile van Sebille<em...@fenx.com> wrote: > On 7/10/2009 11:29 AM Eduardo Vieira said... >> >> Hello! I have the code below to update a database from a csv file. I >> have tested one time and it has worked fine, but I'm a bit fearful >> that it should work right as I am updating a database and don't want >> to cause troubles into the system. >> Is this code safe for my personal use? > > Looks OK to me -- note one small change I'd make (move myconn and mycursor > to after __main__ test) , but even that's not critical. Well, I thought in the case I needed to import this module then I'd have to put it there, right?
> >> the update code is in a function, but the rest of the code to connect >> and disconnect is outside the function. I thought this was a good idea >> because for each line iterated in the csv file, there is a call to the >> function to update the database with the data from the csv file. So, >> using the 'global' inside the function is ok, or maybe not? > > Looks like you don't need the global at all. Have you tried without it? > > Oh, yeah, I was getting confuse on that... probably because a another case where I did need to use the 'global' declaration _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor