astro.database package

Submodules

astro.database.DBFitsHeader module

Provide database access to FITS headers

class astro.database.DBFitsHeader.Header(entries)

Bases: object

astro.database.DBFitsHeader.create_tables()
astro.database.DBFitsHeader.get_card_key(item)

Return the KEYWORD part of a FITS CARD

astro.database.DBFitsHeader.get_header(rawfitsdata)
astro.database.DBFitsHeader.get_header_list(rawfitsdata, exts=[])

Return a list of DARMA header objects corresponding to headers as close as they were to those in the original RawFitsData.

exts: optional list of extensions to return ([] = all extenstions)
astro.database.DBFitsHeader.get_primary_header(rawfitsdata)

Return the primary FITS header from this RawFitsData

astro.database.DBFitsHeader.get_unique_header(rawfitsdata)

Return a logical merge of all the RawFitsData headers.

NOTE: Any keywords common to more than one header are overwritten by
the most recent value (i.e., from the last header merged).
astro.database.DBFitsHeader.insertBOOL(**kwargs)
astro.database.DBFitsHeader.insertDATE(**kwargs)
astro.database.DBFitsHeader.insertDOUBLE(**kwargs)
astro.database.DBFitsHeader.insertINTEGER(**kwargs)
astro.database.DBFitsHeader.insertITEM(cursor=None, fileid=None, extension=None, position=None, card=None, item=None, comment=None, tablename=None, valueformat=':6')
astro.database.DBFitsHeader.insertNOTHING(**kwargs)
astro.database.DBFitsHeader.insertOTHER(cursor=None, fileid=None, extension=None, position=None, card=None, **kwargs)
astro.database.DBFitsHeader.insertSTRING(**kwargs)
astro.database.DBFitsHeader.insert_header(rawfitsdata)
astro.database.DBFitsHeader.select_from_header(rawfitsdata, keyword, operator, value, type)

Select method specifically to query values out of RawFitsData headers.

rawfitsdata: RawFitsData class
keyword: string value of the header keyword
operator: comparison operator as a string (>, <, =, >=, <=, !=)
value: value to compare
type: data type of the value (e.g., str, int, date, etc.)

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.

Usage

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 : yourdatabas.yourdbmachine.yourdomain.aw 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

[global]

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

is READ PROTECTED!!!

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.

Example

#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.name = ‘Jansens’ # Change the value of a string attribute jansens.age = 71 # Change the value of an integer attribute