CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
data_sources.sqlite_schema Class Reference
Inheritance diagram for data_sources.sqlite_schema:
data_sources.data_source data_sources.node

Public Member Functions

def __init__ (self, sqlite_file_name)
 
def data (self)
 
- Public Member Functions inherited from data_sources.data_source
def __init__ (self)
 
def __repr__ (self)
 
def get_data (self)
 
- Public Member Functions inherited from data_sources.node
def __init__ (self, data=None)
 
def __str__ (self)
 
def add_child (self, node_data)
 
def child (self, index)
 
def children (self)
 
def data (self)
 
def is_leaf (self)
 
def left_child (self)
 
def right_child (self)
 

Private Attributes

 _data
 
 _file_name
 

Detailed Description

Definition at line 79 of file data_sources.py.

Constructor & Destructor Documentation

◆ __init__()

def data_sources.sqlite_schema.__init__ (   self,
  sqlite_file_name 
)

Definition at line 81 of file data_sources.py.

81  def __init__(self, sqlite_file_name):
82  self._file_name = sqlite_file_name
83  # import sqlite3 and connect to the database file
84  import sqlite3
85  connection = sqlite3.connect(self._file_name)
86  cursor = connection.cursor()
87  if query_object == None:
88  # try to query the file to get table and column data
89  tables = cursor.execute("select name from sqlite_master where type = 'table'")
90 
91  # now build a mapping of tables to columns - with a dictionary
92  table_to_columns = {}
93  for table in tables.fetchall():
94  table_to_columns[table[0]] = []
95  # now query columns for this table
96  columns = cursor.execute("pragma table_info(%s)" % table[0])
97  for column in columns.fetchall():
98  table_to_columns[table[0]].append(str(column[1]))
99 
100  # now query with the mapping
101  table_to_data = {}
102  for table in table_to_columns:
103  # query with all columns
104  column_string = ",".join(table_to_columns[table])
105  sql_query = "select %s from %s" % (column_string, table)
106  results = cursor.execute(sql_query).fetchall()
107  for n in range(0, len(results)):
108  results[n] = dict(list(zip(table_to_columns[table], list(map(str, results[n])))))
109  table_to_data[str(table)] = results
110  self._data = json_data_node.make(table_to_data)
111  else:
112  sql_query = query_object.to_sql()
113 
def __init__(self, dataset, job_number, job_id, job_name, isDA, isMC, applyBOWS, applyEXTRACOND, extraconditions, runboundary, lumilist, intlumi, maxevents, gt, allFromGT, alignmentDB, alignmentTAG, apeDB, apeTAG, bowDB, bowTAG, vertextype, tracktype, refittertype, ttrhtype, applyruncontrol, ptcut, CMSSW_dir, the_dir)
OutputIterator zip(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp)
static std::string join(char **cmd)
Definition: RemoteFile.cc:19
#define str(s)

Member Function Documentation

◆ data()

def data_sources.sqlite_schema.data (   self)

Definition at line 114 of file data_sources.py.

References data_sources.node._data.

Referenced by data_sources.json_list.as_dicts(), data_sources.json_list.as_table(), data_sources.json_list.get_members(), and data_sources.json_list.last().

114  def data(self):
115  return self._data
116 
117 # used for chaining json-navigation methods
118 # when a method is called initially on the data, an object of this class is returned,
119 # then the methods on that object return an object of this class again.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80

Member Data Documentation

◆ _data

data_sources.sqlite_schema._data
private

◆ _file_name

data_sources.sqlite_schema._file_name
private

Definition at line 82 of file data_sources.py.