cgi odbc sql delete ?

Doug Stanfield DOUGS at oceanic.com
Mon May 29 04:27:06 EDT 2000


The usual thing when there is a difference between running interactively and
as a CGI is something to do with permissions.  Because the problem crops up
when you are trying to do a delete I suspect this is the cause.

You probably created the database and when you are running the script
interactively your script, which inherited your permissions, is able to
delete.  When the CGI gets called from the web page it will be running with
the permissions of the web server.  Those are usually deliberately set to
deny such things as deleting.  In other words, read but don't write.

The solution probably depends on your operating system and the web server,
but this is where I'd start to look.

Good luck,

-Doug-

> -----Original Message-----
> From: Rob Elder [mailto:rob at electric-id.com]
> Sent: Saturday, May 27, 2000 9:37 PM
> To: python-list at python.org
> Subject: cgi odbc sql delete ?
> 
> 
> Hello,
> 
> I have a problem that is driving me crazy.
> I have created a set of routines to do sql functions (odbc, 
> access)  in a
> cgi script. When the script runs the Insert routine works but 
> the Delete
> does not. However, in the interactive Python window on the 
> very same server
> both function work fine. The code is referenced below fyi. If 
> I comment the
> actual delete line in the routine out, there is no problem. There is
> something wrong with:
> 
> dbcursor.execute("DELETE FROM userTable WHERE userID = %s" % sysID)
> 
> It probably is a format problem (???) but I don't know what 
> it is. If the
> problem is not obvious, please give me some ideas on how to 
> debug this. I
> have totally run out of ideas. TIA.
> 
> -r
> 
> REFERENCE_________________________
> 
> def DeleteRecord(sysID):  # this does not work cgi but does work
> interactively
> 
>      dbconn = odbc.odbc('xFrame_db')
>      dbcursor = dbconn.cursor()
>      dbcursor.execute("DELETE FROM userTable WHERE userID = 
> %s" % sysID)
>      dbcursor.close()
>      dbconn.close()
> 
> def InsertRecord(sysID):   # this works both interactively and cgi
> 
>      dbconn = odbc.odbc('xFrame_db')
>      dbcursor = dbconn.cursor()
>      dbcursor.execute("INSERT INTO userTable (userID) VALUES 
> (%s)" % sysID)
>      dbcursor.close()
>      dbconn.close()
> 
> 
> 
> 
> -- 
> http://www.python.org/mailman/listinfo/python-list
> 




More information about the Python-list mailing list