15.2.111. camcops_server.cc_modules.cc_dump¶
camcops_server/cc_modules/cc_dump.py
Copyright (C) 2012, University of Cambridge, Department of Psychiatry. Created by Rudolf Cardinal (rnc1001@cam.ac.uk).
This file is part of CamCOPS.
CamCOPS is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
CamCOPS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with CamCOPS. If not, see <https://www.gnu.org/licenses/>.
Methods for providing a dump of data from the server to the web user.
- class camcops_server.cc_modules.cc_dump.DumpController(dst_engine: sqlalchemy.engine.base.Engine, dst_session: sqlalchemy.orm.session.Session, export_options: TaskExportOptions, req: CamcopsRequest)[source]¶
A controller class that manages the copying (dumping) of information from our database to another SQLAlchemy
Engine
/Session
.- __init__(dst_engine: sqlalchemy.engine.base.Engine, dst_session: sqlalchemy.orm.session.Session, export_options: TaskExportOptions, req: CamcopsRequest) None [source]¶
- Parameters
dst_engine – destination SQLAlchemy Engine
dst_session – destination SQLAlchemy Session
export_options –
camcops_server.cc_modules.cc_simpleobjects.TaskExportOptions
- consider_object(src_obj: object) None [source]¶
Think about an SQLAlchemy ORM object. If it comes from a table we want dumped, add this object to the dump.
- gen_all_dest_columns() Generator[Union[sqlalchemy.sql.schema.Column, camcops_server.cc_modules.cc_sqla_coltypes.CamcopsColumn], None, None] [source]¶
Generates all destination columns.
- gen_all_dest_tables() Generator[sqlalchemy.sql.schema.Table, None, None] [source]¶
Generates all destination tables.
- gen_all_dest_tables_for_obj(src_obj: object) Generator[sqlalchemy.sql.schema.Table, None, None] [source]¶
Generates all destination tables for an object.
- get_dest_table_for_est(est: ExtraSummaryTable, add_extra_id_cols: bool = False) sqlalchemy.sql.schema.Table [source]¶
Add an additional summary table to the dump, if it’s not there already. Return the table (from the destination database).
- Parameters
est – a
camcops_server.cc_modules.cc_summaryelement.ExtraSummaryTable
add_extra_id_cols – Add extra ID columns, for the
DB_PATIENT_ID_PER_ROW
export option?
- get_dest_table_for_src_object(src_obj: object) sqlalchemy.sql.schema.Table [source]¶
Produces the destination table for the source object.
- Parameters
src_obj – An SQLAlchemy ORM object. It will not be a
camcops_server.cc_modules.cc_summaryelement.ExtraSummaryTable
; those are handled instead by_get_or_insert_summary_table()
.- Returns
an SQLAlchemy
Table
- camcops_server.cc_modules.cc_dump.copy_tasks_and_summaries(tasks: Iterable[camcops_server.cc_modules.cc_task.Task], dst_engine: sqlalchemy.engine.base.Engine, dst_session: sqlalchemy.orm.session.Session, export_options: TaskExportOptions, req: CamcopsRequest) None [source]¶
Copy a set of tasks, and their associated related information (found by walking the SQLAlchemy ORM tree), to the dump.
- Parameters
tasks – tasks to copy
dst_engine – destination SQLAlchemy Engine
dst_session – destination SQLAlchemy Session
export_options –
camcops_server.cc_modules.cc_simpleobjects.TaskExportOptions