[Tutor] My code to update database

Emile van Sebille emile at fenx.com
Fri Jul 10 22:36:12 CEST 2009


On 7/10/2009 1:03 PM Eduardo Vieira said...
> On Fri, Jul 10, 2009 at 12:51 PM, Emile van Sebille<emile at 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?

Yes -- but that's the place you're shutting things down at, so it made 
sense to me to do the setup in the same spot.  Certainly if you import 
the module, you'd not expect the shutdown code to be implemented 
external to your module, so some restructuring would be needed to 
convert this to utility status.

Emile



More information about the Tutor mailing list