Classes | |
class | DBError |
Error returned by module_db. More... | |
Functions | |
def | row2dict |
Classic SQLite routine for transforming a row of tuple into a dictionnary. More... | |
def | open_db |
Connect to Output DB. More... | |
def | column_list |
Compute list of all db columns. More... | |
def | init_db |
Initialise output database file. More... | |
def | print_element |
Print a database element in a string. More... | |
def | print_optional_argument |
Print some optional arguments of add/update/find_element. More... | |
def | print_database |
Print the entire table as a list of strings. More... | |
def | find_element |
Find an element in a table. More... | |
def | datetime2output |
Look for the corresponding output around a given date (depending on h_accuracy). 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 | reinit_element |
Put a row to the default values. More... | |
def | delete_element |
Delete an element in a table through its ID. More... | |
def | build_db |
Build the Output database for all simulations available. More... | |
Variables | |
tuple | database_path = os.path.join('dir.output','output.db') |
string | database_table = 'simulation' |
dictionary | operation_mode_ids = {'SCIENCE': 0, 'FORECAST': 1, 'EXTENDED': 2} |
def module_db.add_element | ( | table_name, | |
connector, | |||
cursor, | |||
kwargs | |||
) |
Add an element in a table.
If found 0 corresponding element, just add it.
If found 1 corresponding element, put all columns to default values before updating.
If found more than 1 corresponding element, raise DBError.
def module_db.build_db | ( | folder, | |
db_file, | |||
verbose_in, | |||
fid | |||
) |
Build the Output database for all simulations available.
Verbose = 0 or False: no verbose
Verbose = 1 or True: some basic
Verbose > 1: more verbose
Will look into folder/dir.output/SCIENCE|FORECAST
Exclude the following folders/files:
def module_db.column_list | ( | ) |
Compute list of all db columns.
def module_db.datetime2output | ( | table_name, | |
connector, | |||
cursor, | |||
orderby = None , |
|||
ordercol = None , |
|||
kwargs | |||
) |
Look for the corresponding output around a given date (depending on h_accuracy).
Look at corresponding outputs in [datetime_in-h_accuracy,datetime_in+h_accuracy].
def module_db.delete_element | ( | table_name, | |
connector, | |||
cursor, | |||
element_id | |||
) |
Delete an element in a table through its ID.
def module_db.find_element | ( | table_name, | |
connector, | |||
cursor, | |||
orderby = None , |
|||
ordercol = None , |
|||
kwargs | |||
) |
Find an element in a table.
Orderby and ordercol:
def module_db.init_db | ( | db_file, | |
verbose_in, | |||
fid | |||
) |
Initialise output database file.
If already exists, replace it. Old db kept into .old.
Table: simulation
Attributes:
Verbose = 0 or False: no verbose
Verbose = 1 or True: some basic
Verbose > 1: more verbose
def module_db.open_db | ( | db_path, | |
fid, | |||
verbose = 1 |
|||
) |
Connect to Output DB.
If does not exist, initialise it.
def module_db.print_database | ( | table_name, | |
cursor | |||
) |
Print the entire table as a list of strings.
def module_db.print_element | ( | db_element | ) |
Print a database element in a string.
ID id: scraft, heliospheric_model, coronal_model, reference_time, magnetogram_type, operation_mode, date
def module_db.print_optional_argument | ( | kwargs | ) |
Print some optional arguments of add/update/find_element.
scraft: , heliospheric_model: , coronal_model: , reference_time: , magnetogram_type: , operation_mode: , date:
def module_db.reinit_element | ( | table_name, | |
connector, | |||
cursor, | |||
element_id | |||
) |
Put a row to the default values.
def module_db.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 module_db.update_element | ( | table_name, | |
connector, | |||
cursor, | |||
element_id, | |||
kwargs | |||
) |
Update an element in a table through its ID.
tuple module_db.database_path = os.path.join('dir.output','output.db') |
string module_db.database_table = 'simulation' |
dictionary module_db.operation_mode_ids = {'SCIENCE': 0, 'FORECAST': 1, 'EXTENDED': 2} |