leaving the database open

"Ernesto Revilla" <[email protected]> Thu, 26 Feb 2004 00:51:13 +0100
Newsgroups gmane.comp.python.modeling
Message-ID <000501c3fbfa$4d123320$0100a8c0@servidor>
Hi all,

strange thing (for me) that the AdaptorContext does not define a close operation.

Working with SQLite, I only see code to close the database when all channels are closed and the os.environ.get('MDL_TRANSIENT_DB_CONNECTION') is set (to something different as '' and 0).

The problem arose when I executed the mdl_create_DB_schema.py with execfile from within my PyModel definition with execfile with the -R option. The database was open (after running a schema creation). So rerunning the script with some changes in the model, didn't drop the DB.

So I have the following questions:
* does loading the model open the database?
* is it possible to close explicitly the database, i.e. context, so that after the creation of the schema the database is closed?
* what does the MDL_TRANSIENT_DB_CONNECTION mean:
  a) do not close the DB when all cursor have closed, or
  b) the opposite, close the DB when all channels are closed?

If mdl_generate_DB_schema.py is invoked with the -R option, using SQLiteAptor, and the file does not exist, an error is rosen. Perhaps this could be ignored. (-R is: drop the database if it exists). This could be done with the following code in dropDatabaseWithAdministrativeConnectionDictionary:

    try:
      os.unlink(administrativeConnectionDictionary['database'])
    except OSError, exc:
      # ignore if file does not exist, else, reraise exception
      if not exc.errno==2:
        raise

with best regards, Erny



-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id56&alloc_id438&op=click