Martin v. Löwis wrote: > vizcayno schrieb: > > Need your help in the "correct" definition of the next function. If > > necessary, I would like to know about a web site or documentation that > > tells me about best practices in defining functions, especially for > > those that consider the error exceptions management. > > I agree with George Sakkis' remarks. The best way to define this function is > > def ExecuteSQL(cmdSQL, cursor): > return cursor.execute(cmdSQL) > > If this raises an exception, it likely means there is something > wrong with the SQL statement. The program should abort, and the > developer should correct it. > > Regards, > Martin
With respect, I can offer a counter-argument. I have a multi-user server program, with a connection to a database, servicing multiple requests from connected clients. The clients are 'thin' - the business logic resides on the server - so when a client selects an option, the server imports the appropriate module and executes it. If that includes a SQL command, the server connects to the database, executes the command, and returns the result to the client. If there is something wrong with the SQL statement, I do not want to crash the server, I want to notify the client that there was something wrong, so that the offending module can be corrected and reloaded. Frank Millman
-- http://mail.python.org/mailman/listinfo/python-list