pyiron_base.database.interface module
DatabaseAccess class deals with accessing the database
- class pyiron_base.database.interface.IsDatabase
Bases:
ABC
Captures common interface for all database types in pyiron, e.g. SQL/SQLite/FileTable.
- get_db_columns()
Get column names
- Returns:
- list of column names like:
[‘id’, ‘parentid’, ‘masterid’, ‘projectpath’, ‘project’, ‘job’, ‘subjob’, ‘chemicalformula’, ‘status’, ‘hamilton’, ‘hamversion’, ‘username’, ‘computer’, ‘timestart’, ‘timestop’, ‘totalcputime’]
- Return type:
list
- get_job_ids(sql_query, user, project_path, recursive=True)
Return the job IDs matching a specific query
- Parameters:
database (DatabaseAccess) – Database object
sql_query (str) – SQL query to enter a more specific request
user (str) – username of the user whoes user space should be searched
project_path (str) – root_path - this is in contrast to the project_path in GenericPath
recursive (bool) – search subprojects [True/False]
- Returns:
a list of job IDs
- Return type:
list
- get_jobs(sql_query, user, project_path, recursive=True, columns=None)
Internal function to return the jobs as dictionary rather than a pandas.Dataframe
- Parameters:
sql_query (str) – SQL query to enter a more specific request
user (str) – username of the user whoes user space should be searched
project_path (str) – root_path - this is in contrast to the project_path in GenericPath
recursive (bool) – search subprojects [True/False]
columns (list) – by default only the columns [‘id’, ‘project’] are selected, but the user can select a subset of [‘id’, ‘status’, ‘chemicalformula’, ‘job’, ‘subjob’, ‘project’, ‘projectpath’, ‘timestart’, ‘timestop’, ‘totalcputime’, ‘computer’, ‘hamilton’, ‘hamversion’, ‘parentid’, ‘masterid’]
- Returns:
columns are used as keys and point to a list of the corresponding values
- Return type:
dict
- get_table_headings(table_name=None)
Get column names; if given table_name can select one of multiple tables defined in the database, but subclasses may ignore it
- Parameters:
table_name (str) – simple string of a table_name like: ‘jobs_username’
- Returns:
- list of column names like:
[‘id’, ‘parentid’, ‘masterid’, ‘projectpath’, ‘project’, ‘job’, ‘subjob’, ‘chemicalformula’, ‘status’, ‘hamilton’, ‘hamversion’, ‘username’, ‘computer’, ‘timestart’, ‘timestop’, ‘totalcputime’]
- Return type:
list
- item_update(par_dict, item_id)
- job_table(sql_query, user, project_path, recursive=True, columns=None, all_columns=False, sort_by='id', max_colwidth=200, full_table=False, element_lst=None, job_name_contains='', mode: Literal['regex', 'glob'] = 'glob', **kwargs)
Access the job_table.
- Parameters:
sql_query (str) – SQL query to enter a more specific request
user (str) – username of the user whoes user space should be searched
project_path (str) – root_path - this is in contrast to the project_path in GenericPath
recursive (bool) – search subprojects [True/False]
columns (list) – by default only the columns [‘job’, ‘project’, ‘chemicalformula’] are selected, but the user can select a subset of [‘id’, ‘status’, ‘chemicalformula’, ‘job’, ‘subjob’, ‘project’, ‘projectpath’, ‘timestart’, ‘timestop’, ‘totalcputime’, ‘computer’, ‘hamilton’, ‘hamversion’, ‘parentid’, ‘masterid’]
all_columns (bool) – Select all columns - this overwrites the columns option.
sort_by (str) – Sort by a specific column
max_colwidth (int) – set the column width
full_table (bool) – Whether to show the entire pandas table
element_lst (list) – list of elements required in the chemical formular - by default None
job_name_contains (str) – (deprecated) A string which should be contained in every job_name
mode (str) – search mode when kwargs are given.
**kwargs (dict) – Optional arguments for filtering with keys matching the project database column name (eg. status=”finished”). Asterisk can be used to denote a wildcard, for zero or more instances of any character
- Returns:
Return the result as a pandas.Dataframe object
- Return type:
pandas.Dataframe
- set_job_status(status, job_id)
Set status of a job or multiple jobs if job_id is iterable.
- Parameters:
status (str) – status
job_id (int, Iterable) – job id
- property view_mode
Get view_mode - if view_moded is enable pyiron has read only access to the database.
Some implementations do not allow to set this value.
- Returns:
True when view_mode is enabled
- Return type:
bool
- property viewer_mode
Get view_mode - if view_moded is enable pyiron has read only access to the database.
Some implementations do not allow to set this value.
- Returns:
True when view_mode is enabled
- Return type:
bool