SWDatabase
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Pages
Classes | Functions | Variables
database.database_chole Namespace Reference

Classes

class  DBCholeError
 Error returned by database_chole. More...
 

Functions

def create_table
 Create a chole table data in a database For a table name, create all the attributes. More...
 
def row2dict
 Classic SQLite routine for transforming a row of tuple into a dictionnary. More...
 
def open_db
 Open DB in dictionnary mode. More...
 
def init_db
 Initialise output database file. More...
 
def find_element
 Find an element in 1 or multiple tables. More...
 
def add_element
 Add an element in a table. More...
 
def update_element
 Update an element in a table through its ID. More...
 
def delete_element
 Delete an element in a table through its ID. More...
 
def compare_element
 Compare 2 db_elements. More...
 
def printdiff_element
 Show differences between 2 db_elements. More...
 
def fetch_level_choice
 For a given table_name, return the file fetch level it should use. More...
 
def datetime2file
 Look for the file of corresponding coronal hole file for an given day. More...
 
def nearest_sup
 Look for the nearest and newer coronal hole file for an given day. More...
 
def nearest_inf
 Look for the nearest and older coronal hole file for an given day. More...
 
def build_db
 Build the SW database for all files available and for a given table. More...
 

Variables

tuple database_path = os.path.join(path_db,'chole.db')
 
list database_tables
 
list attributes = []
 

Function Documentation

def database.database_chole.add_element (   table_name,
  connector,
  cursor,
  kwargs 
)

Add an element in a table.

If found 0 corresponding element, just add it.
If found more than 1 corresponding element, raise DBCholeError.

Here is the call graph for this function:

Here is the caller graph for this function:

def database.database_chole.build_db (   table_name,
  db_file,
  verbose = 1 
)

Build the SW database for all files available and for a given table.

Verbose = 0 or False: no verbose
Verbose = 1 or True: some basic
Verbose > 1: more verbose
Will look into folder corresponding to fetch type

Here is the call graph for this function:

def database.database_chole.compare_element (   db1,
  db2 
)

Compare 2 db_elements.

For all attribute names (see database_chole_attributes), check if db1[attr_name] == db2[attr_name].

Returns
boolean True if identical
def database.database_chole.create_table (   connector,
  table_name 
)

Create a chole table data in a database For a table name, create all the attributes.

Here is the caller graph for this function:

def database.database_chole.datetime2file (   table_name,
  date_in,
  h_accuracy = 3 
)

Look for the file of corresponding coronal hole file for an given day.

Returns
Corresponding nearest element of the database.
Todo:
Check input.

Here is the call graph for this function:

def database.database_chole.delete_element (   table_name,
  connector,
  cursor,
  element_id 
)

Delete an element in a table through its ID.

def database.database_chole.fetch_level_choice (   table_name)

For a given table_name, return the file fetch level it should use.

Here is the caller graph for this function:

def database.database_chole.find_element (   table_names,
  connector,
  cursor,
  kwargs 
)

Find an element in 1 or multiple tables.

Parameters
[in]table_nameslist of 1 or multiple table names
[in]connector
[in]cursor
[in]kwargsoptional arguments corresponding to database_chole_attributes and their values
[out]resultslist DB element found

Here is the caller graph for this function:

def database.database_chole.init_db (   db_file,
  verbose_in 
)

Initialise output database file.

If already exists, replace it. Old db kept into .old.
Verbose = 0 or False: no verbose
Verbose = 1 or True: some basic
Verbose > 1: more verbose

Here is the call graph for this function:

def database.database_chole.nearest_inf (   table_name,
  date_in 
)

Look for the nearest and older coronal hole file for an given day.

Returns
Corresponding nearest and older element of the database.

Here is the call graph for this function:

def database.database_chole.nearest_sup (   table_name,
  date_in 
)

Look for the nearest and newer coronal hole file for an given day.

Returns
Corresponding nearest and newer element of the database.

Here is the call graph for this function:

def database.database_chole.open_db (   db_filename)

Open DB in dictionnary mode.

Returns
conn,cur connector and cursor

Here is the caller graph for this function:

def database.database_chole.printdiff_element (   db1,
  db2 
)

Show differences between 2 db_elements.

For all attribute names (see database_chole_attributes), if db1[attr_name] != db2[attr_name] print their respective value.

def database.database_chole.row2dict (   cursor,
  row 
)

Classic SQLite routine for transforming a row of tuple into a dictionnary.

Usage: conn comes from sqlite3.connect(db_file)
conn.row_factory = row2dict
IN FACT NO NEED FOR IT!!!
Just call conn.row_factory = sqlite3.Row

def database.database_chole.update_element (   table_name,
  connector,
  cursor,
  element_id,
  kwargs 
)

Update an element in a table through its ID.

Here is the caller graph for this function:

Variable Documentation

list database.database_chole.attributes = []
tuple database.database_chole.database_path = os.path.join(path_db,'chole.db')
list database.database_chole.database_tables
Initial value:
1 = [
2 'OBS_CORONA_SOLARMONITOR_CHIMERA' ,\
3 ]