astro.database package


astro.database.DBFitsHeader module

astro.database.oraclesupport module

astro customization of oraclesupport

Module contents

Database modules

This package contains the modules for the Persistent Object interface.

The modules DBMain, DBMeta, DBProperties, DBProxy and DBSelect together make it possible to mark Objects and their attributes as Persistent. The DBOracle module is an Oracle 9i implementation of the DBProxy interface.


First make sure that you activate the right database engine or deactivate it if you don’t want to use a database. To use Oracle 9i add the following lines to the ~/.awe/Environment.cfg file

database_engine : oracle_9i database_name : database_user : yourusername database_password : yourpasswordhere

If your ~/.awe/Environment.cfg does not exist or is still empty you’ll have to add a first line to define a global section, like


and look at the documentation of the Environment .py module and .cfg file. NB. If your ~/.awe/Environment.cfg file contains a password make sure it


The user only needs to import the DBMain module to make objects persistent. The following import suffices:

from common.database.DBMain import DBObject, persistent

Here `DBObject’ is the class that is to be used as the base class to derive persistent-capable classes from. The `persistent’ function is used to define attributes as persistent in a persistent-capable class.


#If this example is run with an appropriate database engine the creation of #the instances results in the creation of an identical object in the database. #That instance in the database will survive a Python session, whereas running #the example without a database engine will create object that only exist as #long as a Python session exists. #from common.database.DBMain import DBObject, persistent

class Person(DBObject):
name = persistent(‘The name of a person’, str, ‘Jansen’) age = persistent(‘The age of a person’, int, 70)

jansen = Person() # Create a persistent Person object jansens = Person() # Create another persistent Person object = ‘Jansens’ # Change the value of a string attribute jansens.age = 71 # Change the value of an integer attribute