LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Public Member Functions | Public Attributes | List of all members
lsst.daf.butlerUtils.registries.SqliteRegistry Class Reference
Inheritance diagram for lsst.daf.butlerUtils.registries.SqliteRegistry:
lsst.daf.butlerUtils.registries.Registry

Public Member Functions

def __init__
 
def executeQuery
 
- Public Member Functions inherited from lsst.daf.butlerUtils.registries.Registry
def __init__
 

Public Attributes

 conn
 

Additional Inherited Members

- Static Public Member Functions inherited from lsst.daf.butlerUtils.registries.Registry
def create
 

Detailed Description

A SQLite3-based registry.

Definition at line 75 of file registries.py.

Constructor & Destructor Documentation

def lsst.daf.butlerUtils.registries.SqliteRegistry.__init__ (   self,
  location 
)
Constructor.
@param location (string) Path to SQLite3 file

Definition at line 78 of file registries.py.

78 
79  def __init__(self, location):
80  """Constructor.
81  @param location (string) Path to SQLite3 file"""
82 
83  Registry.__init__(self)
84  if os.path.exists(location):
85  self.conn = sqlite3.connect(location)
86  self.conn.text_factory = str
87  else:
88  self.conn = None

Member Function Documentation

def lsst.daf.butlerUtils.registries.SqliteRegistry.executeQuery (   self,
  returnFields,
  joinClause,
  whereFields,
  range,
  values 
)
Extract metadata from the registry.
@param returnFields (list of strings) Metadata fields to be extracted.
@param joinClause   (list of strings) Tables in which metadata fields
            are located.
@param whereFields  (list of tuples) First tuple element is metadata
            field to query; second is the value that field
            must have (often '?').
@param range        (tuple) Value, lower limit, and upper limit for a
            range condition on the metadata.  Any of these can
            be metadata fields.
@param values       (tuple) Tuple of values to be substituted for '?'
            characters in the whereFields values or the range
            values.
@return (list of tuples) All sets of field values that meet the
criteria

Definition at line 90 of file registries.py.

90 
91  values):
92  """Extract metadata from the registry.
93  @param returnFields (list of strings) Metadata fields to be extracted.
94  @param joinClause (list of strings) Tables in which metadata fields
95  are located.
96  @param whereFields (list of tuples) First tuple element is metadata
97  field to query; second is the value that field
98  must have (often '?').
99  @param range (tuple) Value, lower limit, and upper limit for a
100  range condition on the metadata. Any of these can
101  be metadata fields.
102  @param values (tuple) Tuple of values to be substituted for '?'
103  characters in the whereFields values or the range
104  values.
105  @return (list of tuples) All sets of field values that meet the
106  criteria"""
107 
108  if not self.conn:
109  return None
110  cmd = "SELECT DISTINCT "
111  cmd += ", ".join(returnFields)
112  cmd += " FROM " + " NATURAL JOIN ".join(joinClause)
113  whereList = []
114  if whereFields:
115  for k, v in whereFields:
116  whereList.append("(%s = %s)" % (k, v))
117  if range is not None:
118  whereList.append("(%s BETWEEN %s AND %s)" % range)
119  if len(whereList) > 0:
120  cmd += " WHERE " + " AND ".join(whereList)
121  c = self.conn.execute(cmd, values)
122  result = []
123  for row in c:
124  result.append(row)
125  return result

Member Data Documentation

lsst.daf.butlerUtils.registries.SqliteRegistry.conn

Definition at line 84 of file registries.py.


The documentation for this class was generated from the following file: