[mod_python] Database Help

Yandle, Hans Hans.Yandle at cingular.com
Tue Jan 14 13:57:00 EST 2003


Well, I do not have any experience with Oracle db connections. With MS ODBC
connections using the win32 extensions, I have had to issue commit() then
close() for information to take affect. I have used MySQL dbi and PySQLite
with no problems with just commits only. When you run your database update
script, test and see if it is actually committed the data before the
termination of the python script. To my knowledge when a python script
finishes the variables are cleaned up and connections closed. Perhaps the
termination of the python script is causing the buffers or information to be
committed. Maybe a question to the Oracle python dbi maintainer/group might
help.

-----Original Message-----
From: Sean Abrahams [mailto:sa at sfsu.edu]
Sent: Tuesday, January 14, 2003 1:44 PM
To: Yandle, Hans; mod_python at modpython.org
Subject: Re[2]: [mod_python] Database Help


Thanks for all the replies, but I am indeed committing my statement.
Remember I said it worked when not using mod_python =).

Here's my dbDo function:

def dbDo(db, sql):
    dbCon = dbConnect(db)
    dbCursor = dbCon.cursor()

    dbCursor.execute(sql)
    dbCon.commit()

None of this really makes sense because the code seems to run fine,
giving back no errors. It doesn't even work when I tell it to
explicitly run commit via a sql statement.

I'm using cx_Oracle module to connect to an Oracle 8.1.6 database.

In mod_python must you first disconnect from a database, before
connecting to another one, within the same script?

Thanks for the help.

--Sean
    
Tuesday, January 14, 2003, 6:07:32 AM, you wrote:

YH> I am going to make a simple guess here. I might be wrong but I have been
YH> caught off guard when I forget to issue a commit statement. Maybe the
YH> database connections on the updates/inserts are not automatically
YH> committing.

YH> -----Original Message-----
YH> From: Sean Abrahams [mailto:sa at sfsu.edu]
YH> Sent: Monday, January 13, 2003 9:11 PM
YH> To: mod_python at modpython.org
YH> Subject: [mod_python] Database Help


YH> I'm implementing mod_python and everything is working fine, until I
YH> try to pass an UPDATE sql statement to a database.

YH> I'm grabbing info from one database, and inserting/updating into
YH> another database.

YH> When grabbing, I call upon my dbSelect(db, keys, sql, rows) function,
YH> which connects to a specified database (db) and selects the info.
YH> Works great.

YH> To update/insert I call upon my dbDo(db, sql) function. This function
YH> connects to the specified database (db) and runs the sql. Python wise
YH> everything seems to work fine. I call the dbDo and nothing appears to
YH> go wrong. Except when I look at the data in the db, it wasn't updated.

YH> All of this works fine from the interpreter, so I'm thinking it may
YH> deal with the way mod_python handles processes and dbconnections, of
YH> which I know very little of.

YH> Thus, does connecting to two different databases, right after one
YH> another, cause a problem in mod_python? I'm supposing I must change my
YH> dbConnect() function to take this into consideration due to the way
YH> mod_python/apache function.

YH> Some ideas? I want to learn!

YH> Thanks,
YH> --Sean

YH> Running:
YH> Apache/2.0.43 (Debian GNU/Linux) DAV/2 mod_python/3.0.1 Python/2.2.1
YH> cx_Oracle

YH> _______________________________________________
YH> Mod_python mailing list
YH> Mod_python at modpython.org
YH> http://www.modpython.org/mailman/listinfo/mod_python
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.modpython.org/pipermail/mod_python/attachments/20030114/a35ad92e/attachment-0003.htm


More information about the Mod_python mailing list