database.client.base

Base class for basic DB client functions

class accre.database.client.base.DBClientBase(engine=None, meta=None)[source]

Bases: object

Client wrapper for the ACCRE administrative database with convenience methods for common instertions and queries.

This base class only contains very generic methods or ones that do not fit into a category. Most methods should generally be refactored into a mixin class in another module if practical.

add_row(table, **values)[source]

Low-level convenience method to add a row to the specified table. All required fields must be included. For adding users, groups, or other entities with a specific method that method should be used instead.

Parameters:
  • table (sqlalchemy.table) – Table object to perform the insert in

  • values (dict) – field values for the inserted row

dashboard_client_info(vunetid)[source]

Return initial account data for dashboard. Three levels of authentication exist: ACCRE staff, a PI, or another type of user such as a student, a Post Doc Researcher, or another faculty/staff scientist.

Parameters:

vunetid (str) – vunetid of the dashboard user

Returns:

General account information for specific account type

Return type:

result(dict)

show_departmental_hierarchy()[source]

Fetch the complete organizational hierarcy from the database and return it in a semi-structured form. Specifically, Return a dictionary keyed by organization, each value being a dictionary keyed by division, with each value being a dictionary keyed by department having the formatted name as a value, for example: {'vu': {'cas': {'phys': 'Physics and Astronomy'}}}.

Returns:

The Vanderbilt organiztional hierarchy

Return type:

defaultdict(defaultdict(dict(str)))