diff --git a/python/bids_import.py b/python/bids_import.py index 5f3e73a9f..379aa4c6a 100755 --- a/python/bids_import.py +++ b/python/bids_import.py @@ -10,12 +10,12 @@ import lib.exitcode import lib.utilities import lib.physiological -from lib.database import Database -from lib.candidate import Candidate +from lib.database_lib import Database +from lib.candidate import Candidate from lib.bidsreader import BidsReader -from lib.session import Session -from lib.eeg import Eeg -from lib.mri import Mri +from lib.session import Session +from lib.eeg import Eeg +from lib.mri import Mri from lib.database_lib.config import Config __license__ = "GPLv3" diff --git a/python/extract_eeg_bids_archive.py b/python/extract_eeg_bids_archive.py index a5724c624..97a485647 100755 --- a/python/extract_eeg_bids_archive.py +++ b/python/extract_eeg_bids_archive.py @@ -7,7 +7,7 @@ import re from lib.lorisgetopt import LorisGetOpt from lib.imaging_io import ImagingIO -from lib.database import Database +from lib.database_lib import Database from lib.database_lib.config import Config from lib.exitcode import SUCCESS, BAD_CONFIG_SETTING from lib.log import Log diff --git a/python/ingest_eeg_bids_datasets.py b/python/ingest_eeg_bids_datasets.py index e62e78d0c..a3922fbb6 100755 --- a/python/ingest_eeg_bids_datasets.py +++ b/python/ingest_eeg_bids_datasets.py @@ -5,7 +5,7 @@ import os import sys from lib.lorisgetopt import LorisGetOpt -from lib.database import Database +from lib.database_lib import Database from lib.database_lib.config import Config from lib.exitcode import SUCCESS, INVALID_ARG import subprocess @@ -112,7 +112,7 @@ def main(): if not session_data: print('Session ID ' + eeg_dataset['SessionID'] + ' associated with UploadID ' + uploadid + ' does not exist.') sys.exit(INVALID_ARG) - + candid = session_data[0]['CandID'] pscid = session_data[0]['PSCID'] visit = session_data[0]['Visit_label'] @@ -150,13 +150,13 @@ def main(): # Assume eeg and raw data for now eeg_path = os.path.join(path, 'eeg') command = 'python ' + script + ' -p ' + profile + ' -d ' + eeg_path + ' --nobidsvalidation --nocopy --type raw' - + try: result = subprocess.run(command, shell = True, capture_output=True) if result.stdout: print(result.stdout.decode('utf-8')) - + if result.stderr: print( f'ERROR: EEG Dataset with uploadID {uploadid} ingestion log:\n ' + result.stderr.decode('utf-8') @@ -177,7 +177,7 @@ def main(): "UPDATE electrophysiology_uploader SET Status = 'Failed Ingestion' WHERE UploadID = %s", (uploadid,) ) - + # TODO: reupload of archive after ingestion # Delete if already exist diff --git a/python/lib/candidate.py b/python/lib/candidate.py index b2bb20c72..e25fce319 100644 --- a/python/lib/candidate.py +++ b/python/lib/candidate.py @@ -16,7 +16,7 @@ class Candidate: :Example: from lib.candidate import Candidate - from lib.database import Database + from lib.database_lib import Database # database connection db = Database(config.mysql, verbose) diff --git a/python/lib/database.py b/python/lib/database.py deleted file mode 100644 index fa182d7f3..000000000 --- a/python/lib/database.py +++ /dev/null @@ -1,277 +0,0 @@ -"""Allows LORIS database connectivity for LORIS-MRI python code base""" - -import MySQLdb -import sys -import lib.exitcode - - -__license__ = "GPLv3" - - -class Database: - """ - This class performs common tasks related to database connectivity between - the LORIS-MRI python code base and the LORIS backend database. - - :Example: - - from lib.database import Database - - db = Database(config.mysql, verbose) - - db.connect() - - # to select data corresponding to specific parameters - results = db.pselect( - "SELECT CandID FROM candidate WHERE Active = %s AND Sex = %s", - ('Y', 'Male') - ) - - # to select data without any specific parameter - results = db.pselect( - "SELECT CandID FROM candidate" - ) # args is optional in db.pselect - - # to insert multiple rows - db.insert( - 'media', - ('session_id', 'file_name', 'data_dir'), - [ - ('6834', 'bla', 'bndjf'), - ('6834', 'blu', 'blui') - ] - ) - - # to insert one row and return the last inserted ID - last_id = db.insert( - 'media', - ('session_id', 'file_name', 'data_dir'), - [ - ('6834', 'bla', 'bndjf') - ], - True - ) # get_last_id is default to False in db.insert - - # to update data - db.update( - "UPDATE media SET file_name = %s WHERE ID = %s, - ('filename.txt', '1') - ) - - db.disconnect() - """ - - def __init__(self, credentials, verbose): - """ - Constructor method for the Database class. - - :param credentials: LORIS database credentials - :type credentials: dict - :param verbose : whether to be verbose or not - :type verbose : bool - """ - - self.verbose = verbose - - # grep database credentials - default_port = 3306 - self.db_name = credentials['database'] - self.user_name = credentials['username'] - self.password = credentials['passwd'] - self.host_name = credentials['host'] - port = credentials['port'] - - if not self.user_name: - raise Exception("\nUser name cannot be empty string.\n") - if not self.db_name: - raise Exception("\nDatabase name cannot be empty string.\n") - if not self.host_name: - raise Exception("\nDatabase host cannot be empty string.\n") - - self.port = int(port) if port else default_port - - def connect(self): - """ - Attempts to connect to the database using the connection parameters - passed at construction time. This method will throw a - DatabaseException if the connection could not be established. - """ - - connect_statement = "\nConnecting to:" \ - "\n\tdatabase: " + self.db_name + \ - "\n\tusername: " + self.user_name + \ - "\n\thostname: " + self.host_name + \ - "\n\tport : " + str(self.port) + '\n' - if self.verbose: - print(connect_statement) - - try: - self.con = MySQLdb.connect( - host=self.host_name, - user=self.user_name, - passwd=self.password, - port=self.port, - db=self.db_name - ) - # self.cnx.cursor = self.cnx.cursor(prepared=True) - except MySQLdb.Error as err: - raise Exception("Database connection failure: " + format(err)) - - def pselect(self, query, args=None): - """ - Executes a select query on the database. This method will first prepare - the statement passed as parameter before sending the request to the - database. - - :param query: select query to execute (containing the argument - placeholders if any - :type query: str - :param args: arguments to replace the placeholders with - :type args: tuple - - :return: list of dictionaries with MySQL column header name - :rtype: list of dict - """ - if self.verbose: - print("\nExecuting query:\n\t" + query + "\n") - if args: - print("With arguments:\n\t" + str(args) + "\n") - - try: - cursor = self.con.cursor(MySQLdb.cursors.DictCursor) - cursor.execute(query, args) if args else cursor.execute(query) - results = cursor.fetchall() - cursor.close() - except MySQLdb.Error as err: - raise Exception("Select query failure: " + format(err)) - - return results - - def insert(self, table_name, column_names, values, get_last_id=False): - """ - Inserts records in a given database table with the specified column - values. This method will raise an exception if the record cannot be - inserted. - - :param table_name : name of the database table to insert into - :type table_name : str - :param column_names: name of the table's columns to insert into - :type column_names: tuple - :param values : list of values to insert into the table - :type values : list - - :return: the last ID that have been inserted into the database - :rtype: int - """ - - placeholders = ','.join(map(lambda x: '%s', column_names)) - - query = "INSERT INTO %s (%s) VALUES (%s)" % ( - table_name, ', '.join(column_names), placeholders - ) - - if self.verbose: - print("\nExecuting query:\n\t" + query + "\n" - + "With arguments:\n\t" + str(values) + "\n") - - try: - cursor = self.con.cursor() - if isinstance(values, list): - # if values is a list, use cursor.executemany - # (to execute multiple inserts at once) - cursor.executemany(query, values) - else: - # else, values is a tuple and want to execute only one insert - cursor.execute(query, values) - self.con.commit() - last_id = cursor.lastrowid - cursor.close() - except MySQLdb.Error as err: - raise Exception("Insert query failure: " + format(err)) - - if get_last_id: - return last_id - - def update(self, query, args): - """ - Executes an update query on the database. This method will first prepare - the statement passed as parameter before sending the request to the - database. - - :param query: update query to be run - :type query: str - :param args : arguments to replace the placeholders with - :type args : tuple - """ - - if self.verbose: - print("\nExecuting query:\n\t" + query + "\n" - + "With arguments:\n\t" + str(args) + "\n") - - try: - cursor = self.con.cursor() - cursor.execute(query, args) - self.con.commit() - except MySQLdb.Error as err: - raise Exception("Update query failure: " + format(err)) - - def grep_id_from_lookup_table(self, id_field_name, table_name, where_field_name, - where_value, insert_if_not_found=None): - """ - Greps an ID from a given lookup table based on the provided value. - - :param id_field_name : name of the ID field in the table - :type id_field_name : str - :param table_name : name of the lookup table - :type table_name : str - :param where_field_name : name of the field to use to find the ID - :type where_field_name : str - :param where_value : value of the field to use to find the ID - :type where_value : str - :param insert_if_not_found: whether to insert a new row in the lookup table - if no entry was found for the provided value - :type insert_if_not_found: bool - - :return: ID found in the lookup table - :rtype: int - - """ - - query = "SELECT " + id_field_name + " " \ - "FROM " + table_name + " " \ - "WHERE " + where_field_name + " = %s" - - result = self.pselect(query=query, args=(where_value,)) - id = result[0][id_field_name] if result else None - - if not id and insert_if_not_found: - id = self.insert( - table_name = table_name, - column_names = (where_field_name,), - values = (where_value,), - get_last_id = True - ) - - if not id: - message = "\nERROR: " + where_value + " " + where_field_name + \ - " does not exist in " + table_name + " database table\n" - print(message) - sys.exit(lib.exitcode.SELECT_FAILURE) - - return id - - def disconnect(self): - """ - Terminates the connection previously instantiated to the database if a - connection was previously established. - """ - - if hasattr(self, 'cnx'): - if self.verbose: - print("\nDisconnecting from the database") - - try: - self.con.close() - except MySQLdb.Error as err: - message = "Database disconnection failure: " + format(err) - raise Exception(message) diff --git a/python/lib/database_lib/__init__.py b/python/lib/database_lib/__init__.py index e69de29bb..99dee85b4 100644 --- a/python/lib/database_lib/__init__.py +++ b/python/lib/database_lib/__init__.py @@ -0,0 +1,277 @@ +"""Allows LORIS database connectivity for LORIS-MRI python code base""" + +import MySQLdb +import sys +import lib.exitcode + + +__license__ = "GPLv3" + + +class Database: + """ + This class performs common tasks related to database connectivity between + the LORIS-MRI python code base and the LORIS backend database. + + :Example: + + from lib.database_lib import Database + + db = Database(config.mysql, verbose) + + db.connect() + + # to select data corresponding to specific parameters + results = db.pselect( + "SELECT CandID FROM candidate WHERE Active = %s AND Sex = %s", + ('Y', 'Male') + ) + + # to select data without any specific parameter + results = db.pselect( + "SELECT CandID FROM candidate" + ) # args is optional in db.pselect + + # to insert multiple rows + db.insert( + 'media', + ('session_id', 'file_name', 'data_dir'), + [ + ('6834', 'bla', 'bndjf'), + ('6834', 'blu', 'blui') + ] + ) + + # to insert one row and return the last inserted ID + last_id = db.insert( + 'media', + ('session_id', 'file_name', 'data_dir'), + [ + ('6834', 'bla', 'bndjf') + ], + True + ) # get_last_id is default to False in db.insert + + # to update data + db.update( + "UPDATE media SET file_name = %s WHERE ID = %s, + ('filename.txt', '1') + ) + + db.disconnect() + """ + + def __init__(self, credentials, verbose): + """ + Constructor method for the Database class. + + :param credentials: LORIS database credentials + :type credentials: dict + :param verbose : whether to be verbose or not + :type verbose : bool + """ + + self.verbose = verbose + + # grep database credentials + default_port = 3306 + self.db_name = credentials['database'] + self.user_name = credentials['username'] + self.password = credentials['passwd'] + self.host_name = credentials['host'] + port = credentials['port'] + + if not self.user_name: + raise Exception("\nUser name cannot be empty string.\n") + if not self.db_name: + raise Exception("\nDatabase name cannot be empty string.\n") + if not self.host_name: + raise Exception("\nDatabase host cannot be empty string.\n") + + self.port = int(port) if port else default_port + + def connect(self): + """ + Attempts to connect to the database using the connection parameters + passed at construction time. This method will throw a + DatabaseException if the connection could not be established. + """ + + connect_statement = "\nConnecting to:" \ + "\n\tdatabase: " + self.db_name + \ + "\n\tusername: " + self.user_name + \ + "\n\thostname: " + self.host_name + \ + "\n\tport : " + str(self.port) + '\n' + if self.verbose: + print(connect_statement) + + try: + self.con = MySQLdb.connect( + host=self.host_name, + user=self.user_name, + passwd=self.password, + port=self.port, + db=self.db_name + ) + # self.cnx.cursor = self.cnx.cursor(prepared=True) + except MySQLdb.Error as err: + raise Exception("Database connection failure: " + format(err)) + + def pselect(self, query, args=None): + """ + Executes a select query on the database. This method will first prepare + the statement passed as parameter before sending the request to the + database. + + :param query: select query to execute (containing the argument + placeholders if any + :type query: str + :param args: arguments to replace the placeholders with + :type args: tuple + + :return: list of dictionaries with MySQL column header name + :rtype: list of dict + """ + if self.verbose: + print("\nExecuting query:\n\t" + query + "\n") + if args: + print("With arguments:\n\t" + str(args) + "\n") + + try: + cursor = self.con.cursor(MySQLdb.cursors.DictCursor) + cursor.execute(query, args) if args else cursor.execute(query) + results = cursor.fetchall() + cursor.close() + except MySQLdb.Error as err: + raise Exception("Select query failure: " + format(err)) + + return results + + def insert(self, table_name, column_names, values, get_last_id=False): + """ + Inserts records in a given database table with the specified column + values. This method will raise an exception if the record cannot be + inserted. + + :param table_name : name of the database table to insert into + :type table_name : str + :param column_names: name of the table's columns to insert into + :type column_names: tuple + :param values : list of values to insert into the table + :type values : list + + :return: the last ID that have been inserted into the database + :rtype: int + """ + + placeholders = ','.join(map(lambda x: '%s', column_names)) + + query = "INSERT INTO %s (%s) VALUES (%s)" % ( + table_name, ', '.join(column_names), placeholders + ) + + if self.verbose: + print("\nExecuting query:\n\t" + query + "\n" + + "With arguments:\n\t" + str(values) + "\n") + + try: + cursor = self.con.cursor() + if isinstance(values, list): + # if values is a list, use cursor.executemany + # (to execute multiple inserts at once) + cursor.executemany(query, values) + else: + # else, values is a tuple and want to execute only one insert + cursor.execute(query, values) + self.con.commit() + last_id = cursor.lastrowid + cursor.close() + except MySQLdb.Error as err: + raise Exception("Insert query failure: " + format(err)) + + if get_last_id: + return last_id + + def update(self, query, args): + """ + Executes an update query on the database. This method will first prepare + the statement passed as parameter before sending the request to the + database. + + :param query: update query to be run + :type query: str + :param args : arguments to replace the placeholders with + :type args : tuple + """ + + if self.verbose: + print("\nExecuting query:\n\t" + query + "\n" + + "With arguments:\n\t" + str(args) + "\n") + + try: + cursor = self.con.cursor() + cursor.execute(query, args) + self.con.commit() + except MySQLdb.Error as err: + raise Exception("Update query failure: " + format(err)) + + def grep_id_from_lookup_table(self, id_field_name, table_name, where_field_name, + where_value, insert_if_not_found=None): + """ + Greps an ID from a given lookup table based on the provided value. + + :param id_field_name : name of the ID field in the table + :type id_field_name : str + :param table_name : name of the lookup table + :type table_name : str + :param where_field_name : name of the field to use to find the ID + :type where_field_name : str + :param where_value : value of the field to use to find the ID + :type where_value : str + :param insert_if_not_found: whether to insert a new row in the lookup table + if no entry was found for the provided value + :type insert_if_not_found: bool + + :return: ID found in the lookup table + :rtype: int + + """ + + query = "SELECT " + id_field_name + " " \ + "FROM " + table_name + " " \ + "WHERE " + where_field_name + " = %s" + + result = self.pselect(query=query, args=(where_value,)) + id = result[0][id_field_name] if result else None + + if not id and insert_if_not_found: + id = self.insert( + table_name = table_name, + column_names = (where_field_name,), + values = (where_value,), + get_last_id = True + ) + + if not id: + message = "\nERROR: " + where_value + " " + where_field_name + \ + " does not exist in " + table_name + " database table\n" + print(message) + sys.exit(lib.exitcode.SELECT_FAILURE) + + return id + + def disconnect(self): + """ + Terminates the connection previously instantiated to the database if a + connection was previously established. + """ + + if hasattr(self, 'cnx'): + if self.verbose: + print("\nDisconnecting from the database") + + try: + self.con.close() + except MySQLdb.Error as err: + message = "Database disconnection failure: " + format(err) + raise Exception(message) diff --git a/python/lib/database_lib/candidate_db.py b/python/lib/database_lib/candidate_db.py index bbe4e92d3..958caaf6d 100644 --- a/python/lib/database_lib/candidate_db.py +++ b/python/lib/database_lib/candidate_db.py @@ -11,7 +11,7 @@ class CandidateDB: :Example: from lib.database_lib.candidate_db import CandidateDB - from lib.database import Database + from lib.database_lib import Database # database connection db = Database(config.mysql, verbose) diff --git a/python/lib/database_lib/config.py b/python/lib/database_lib/config.py index a5030762c..22dd12348 100644 --- a/python/lib/database_lib/config.py +++ b/python/lib/database_lib/config.py @@ -11,7 +11,7 @@ class Config: :Example: from lib.database_lib.config import Config - from lib.database import Database + from lib.database_lib import Database # database connection db = Database(config.mysql, verbose) diff --git a/python/lib/database_lib/files.py b/python/lib/database_lib/files.py index 4fab37e06..dd5a32e67 100644 --- a/python/lib/database_lib/files.py +++ b/python/lib/database_lib/files.py @@ -12,7 +12,7 @@ class Files: :Example: from lib.files import Files - from lib.database import Database + from lib.database_lib import Database # database connection db = Database(config.mysql, verbose) diff --git a/python/lib/database_lib/mri_candidate_errors.py b/python/lib/database_lib/mri_candidate_errors.py index 25b70e5e7..eec21fefc 100644 --- a/python/lib/database_lib/mri_candidate_errors.py +++ b/python/lib/database_lib/mri_candidate_errors.py @@ -11,7 +11,7 @@ class MriCandidateErrors: :Example: from lib.mri_candidate_errors import MriCandidateErrors - from lib.database import Database + from lib.database_lib import Database # database connection db = Database(config.mysql, verbose) diff --git a/python/lib/database_lib/mri_protocol.py b/python/lib/database_lib/mri_protocol.py index 86fa29035..60230b013 100644 --- a/python/lib/database_lib/mri_protocol.py +++ b/python/lib/database_lib/mri_protocol.py @@ -11,7 +11,7 @@ class MriProtocol: :Example: from lib.mri_protocol import MriProtocol - from lib.database import Database + from lib.database_lib import Database # database connection db = Database(config.mysql, verbose) diff --git a/python/lib/database_lib/mri_protocol_checks.py b/python/lib/database_lib/mri_protocol_checks.py index 1bdd02aac..b6a8dd7c0 100644 --- a/python/lib/database_lib/mri_protocol_checks.py +++ b/python/lib/database_lib/mri_protocol_checks.py @@ -11,7 +11,7 @@ class MriProtocolChecks: :Example: from lib.mri_protocol_checks import MriProtocolChecks - from lib.database import Database + from lib.database_lib import Database # database connection db = Database(config.mysql, verbose) diff --git a/python/lib/database_lib/mri_protocol_violated_scans.py b/python/lib/database_lib/mri_protocol_violated_scans.py index fd65b55fa..87c9f734c 100644 --- a/python/lib/database_lib/mri_protocol_violated_scans.py +++ b/python/lib/database_lib/mri_protocol_violated_scans.py @@ -11,7 +11,7 @@ class MriProtocolViolatedScans: :Example: from lib.mri_protocol_violated_scans import MriProtocolViolatedScans - from lib.database import Database + from lib.database_lib import Database # database connection db = Database(config.mysql, verbose) diff --git a/python/lib/database_lib/mri_scan_type.py b/python/lib/database_lib/mri_scan_type.py index 64f4759b6..bf14fb0ee 100644 --- a/python/lib/database_lib/mri_scan_type.py +++ b/python/lib/database_lib/mri_scan_type.py @@ -11,7 +11,7 @@ class MriScanType: :Example: from lib.mri_scan_type import MriScanType - from lib.database import Database + from lib.database_lib import Database # database connection db = Database(config.mysql, verbose) diff --git a/python/lib/database_lib/mri_scanner.py b/python/lib/database_lib/mri_scanner.py index 7ea0cbc52..edc8a0d2d 100644 --- a/python/lib/database_lib/mri_scanner.py +++ b/python/lib/database_lib/mri_scanner.py @@ -13,7 +13,7 @@ class MriScanner: :Example: from lib.mri_scanner import MriScanner - from lib.database import Database + from lib.database_lib import Database # database connection db = Database(config.mysql, verbose) diff --git a/python/lib/database_lib/mri_upload_db.py b/python/lib/database_lib/mri_upload_db.py index c636429e2..5bf4a24d3 100644 --- a/python/lib/database_lib/mri_upload_db.py +++ b/python/lib/database_lib/mri_upload_db.py @@ -10,7 +10,7 @@ class MriUploadDB: :Example: from lib.mri_upload import MriUploadDB - from lib.database import Database + from lib.database_lib import Database # database connection db = Database(config.mysql, verbose) diff --git a/python/lib/database_lib/mri_violations_log.py b/python/lib/database_lib/mri_violations_log.py index 517c97a54..a52950533 100644 --- a/python/lib/database_lib/mri_violations_log.py +++ b/python/lib/database_lib/mri_violations_log.py @@ -11,7 +11,7 @@ class MriViolationsLog: :Example: from lib.mri_violations_log import MriViolationsLog - from lib.database import Database + from lib.database_lib import Database # database connection db = Database(config.mysql, verbose) diff --git a/python/lib/database_lib/notification.py b/python/lib/database_lib/notification.py index 6c873fa06..33892b6b1 100644 --- a/python/lib/database_lib/notification.py +++ b/python/lib/database_lib/notification.py @@ -12,7 +12,7 @@ class Notification: :Example: from lib.notification import Notification - from lib.database import Database + from lib.database_lib import Database # database connection db = Database(config.mysql, verbose) diff --git a/python/lib/database_lib/parameter_file.py b/python/lib/database_lib/parameter_file.py index 720431389..603fca396 100644 --- a/python/lib/database_lib/parameter_file.py +++ b/python/lib/database_lib/parameter_file.py @@ -10,7 +10,7 @@ class ParameterFile: :Example: from lib.parameter_file import ParameterFile - from lib.database import Database + from lib.database_lib import Database # database connection db = Database(config.mysql, verbose) diff --git a/python/lib/database_lib/parameter_type.py b/python/lib/database_lib/parameter_type.py index 421cae4a1..a6c2f60b3 100644 --- a/python/lib/database_lib/parameter_type.py +++ b/python/lib/database_lib/parameter_type.py @@ -10,7 +10,7 @@ class ParameterType: :Example: from lib.parameter_type import ParameterType - from lib.database import Database + from lib.database_lib import Database # database connection db = Database(config.mysql, verbose) diff --git a/python/lib/database_lib/project_cohort_rel.py b/python/lib/database_lib/project_cohort_rel.py index 06acb9197..c3e3ccde4 100644 --- a/python/lib/database_lib/project_cohort_rel.py +++ b/python/lib/database_lib/project_cohort_rel.py @@ -11,7 +11,7 @@ class ProjectCohortRel: :Example: from lib.database_lib.project_cohort_rel import ProjectCohortRel - from lib.database import Database + from lib.database_lib import Database # database connection db = Database(config.mysql, verbose) diff --git a/python/lib/database_lib/session_db.py b/python/lib/database_lib/session_db.py index 764015bd1..b95311585 100644 --- a/python/lib/database_lib/session_db.py +++ b/python/lib/database_lib/session_db.py @@ -11,7 +11,7 @@ class SessionDB: :Example: from lib.database_lib.session_db import SessionDB - from lib.database import Database + from lib.database_lib import Database # database connection db = Database(config.mysql, verbose) diff --git a/python/lib/database_lib/site.py b/python/lib/database_lib/site.py index 192befebd..1af4367bb 100644 --- a/python/lib/database_lib/site.py +++ b/python/lib/database_lib/site.py @@ -11,7 +11,7 @@ class Site: :Example: from lib.site import Site - from lib.database import Database + from lib.database_lib import Database # database connection db = Database(config.mysql, verbose) diff --git a/python/lib/database_lib/tarchive.py b/python/lib/database_lib/tarchive.py index ec22865a0..f881f6c98 100644 --- a/python/lib/database_lib/tarchive.py +++ b/python/lib/database_lib/tarchive.py @@ -11,7 +11,7 @@ class Tarchive: :Example: from lib.tarchive import Tarchive - from lib.database import Database + from lib.database_lib import Database # database connection db = Database(config.mysql, verbose) diff --git a/python/lib/database_lib/tarchive_series.py b/python/lib/database_lib/tarchive_series.py index d0f8c5ac0..2586848c8 100644 --- a/python/lib/database_lib/tarchive_series.py +++ b/python/lib/database_lib/tarchive_series.py @@ -11,7 +11,7 @@ class TarchiveSeries: :Example: from lib.tarchive_series import TarchiveSeries - from lib.database import Database + from lib.database_lib import Database # database connection db = Database(config.mysql, verbose) diff --git a/python/lib/database_lib/visit_windows.py b/python/lib/database_lib/visit_windows.py index 14e1636ee..f16ae8930 100644 --- a/python/lib/database_lib/visit_windows.py +++ b/python/lib/database_lib/visit_windows.py @@ -11,7 +11,7 @@ class VisitWindows: :Example: from lib.visit_windows import VisitWindows - from lib.database import Database + from lib.database_lib import Database # database connection db = Database(config.mysql, verbose) diff --git a/python/lib/dcm2bids_imaging_pipeline_lib/base_pipeline.py b/python/lib/dcm2bids_imaging_pipeline_lib/base_pipeline.py index 01176531c..70c3a82c4 100644 --- a/python/lib/dcm2bids_imaging_pipeline_lib/base_pipeline.py +++ b/python/lib/dcm2bids_imaging_pipeline_lib/base_pipeline.py @@ -9,7 +9,7 @@ from lib.database_lib.candidate_db import CandidateDB from lib.database_lib.config import Config from lib.database_lib.visit_windows import VisitWindows -from lib.database import Database +from lib.database_lib import Database from lib.dicom_archive import DicomArchive from lib.imaging import Imaging from lib.log import Log diff --git a/python/lib/dicom_archive.py b/python/lib/dicom_archive.py index 47f3b87b4..8497d473c 100644 --- a/python/lib/dicom_archive.py +++ b/python/lib/dicom_archive.py @@ -14,7 +14,7 @@ class DicomArchive: :Example: - from lib.database import Database + from lib.database_lib import Database from lib.dicom_archive import DicomArchive # database connection diff --git a/python/lib/eeg.py b/python/lib/eeg.py index efd5bf8e2..5baea46d3 100755 --- a/python/lib/eeg.py +++ b/python/lib/eeg.py @@ -28,8 +28,8 @@ class Eeg: :Example: from lib.bidsreader import BidsReader - from lib.eeg import Eeg - from lib.database import Database + from lib.eeg import Eeg + from lib.database_lib import Database from lib.database_lib.config import Config # database connection diff --git a/python/lib/imaging.py b/python/lib/imaging.py index 3c3331437..420417f9e 100644 --- a/python/lib/imaging.py +++ b/python/lib/imaging.py @@ -32,7 +32,7 @@ class Imaging: :Example: from lib.imaging import Imaging - from lib.database import Database + from lib.database_lib import Database # database connection db = Database(config.mysql, verbose) diff --git a/python/lib/imaging_upload.py b/python/lib/imaging_upload.py index 00e5889cb..f9d28fadf 100644 --- a/python/lib/imaging_upload.py +++ b/python/lib/imaging_upload.py @@ -13,7 +13,7 @@ class ImagingUpload: :Example: from lib.imaging_upload import ImagingUpload - from lib.database import Database + from lib.database_lib import Database # database connection db = Database(config.mysql, verbose) diff --git a/python/lib/lorisgetopt.py b/python/lib/lorisgetopt.py index c71740bbb..081f1c18a 100644 --- a/python/lib/lorisgetopt.py +++ b/python/lib/lorisgetopt.py @@ -7,7 +7,7 @@ import sys from lib.aws_s3 import AwsS3 -from lib.database import Database +from lib.database_lib import Database from lib.database_lib.config import Config diff --git a/python/lib/mri.py b/python/lib/mri.py index 7ebaabbb2..84fb13353 100644 --- a/python/lib/mri.py +++ b/python/lib/mri.py @@ -25,8 +25,8 @@ class Mri: :Example: from lib.bidsreader import BidsReader - from lib.mri import Mri - from lib.database import Database + from lib.mri import Mri + from lib.database_lib import Database # database connection db = Database(config_file.mysql, verbose) diff --git a/python/lib/physiological.py b/python/lib/physiological.py index 0db6293b1..4b2cbc87a 100755 --- a/python/lib/physiological.py +++ b/python/lib/physiological.py @@ -32,7 +32,7 @@ class Physiological: :Example: from lib.physiological import Physiological - from lib.database import Database + from lib.database_lib import Database # database connection db = Database(config.mysql, verbose) diff --git a/python/lib/session.py b/python/lib/session.py index 81fe021a0..7c91e2c68 100644 --- a/python/lib/session.py +++ b/python/lib/session.py @@ -14,8 +14,8 @@ class Session: :Example: - from lib.session import Session - from lib.database import Database + from lib.session import Session + from lib.database_lib import Database # database connection db = Database(config.mysql, verbose) diff --git a/python/mass_electrophysiology_chunking.py b/python/mass_electrophysiology_chunking.py index baee595b6..e93f7f8a8 100755 --- a/python/mass_electrophysiology_chunking.py +++ b/python/mass_electrophysiology_chunking.py @@ -6,7 +6,7 @@ import sys import getopt import lib.exitcode -from lib.database import Database +from lib.database_lib import Database from lib.physiological import Physiological from lib.database_lib.config import Config diff --git a/python/mass_nifti_pic.py b/python/mass_nifti_pic.py index 589c1ff47..cd8e8b023 100755 --- a/python/mass_nifti_pic.py +++ b/python/mass_nifti_pic.py @@ -7,7 +7,7 @@ import sys import getopt import lib.exitcode -from lib.database import Database +from lib.database_lib import Database from lib.imaging import Imaging from lib.database_lib.config import Config diff --git a/tools/correct_blake2b_and_md5_hashes_in_database.py b/tools/correct_blake2b_and_md5_hashes_in_database.py index 9b5e45ad4..1ac534bcd 100755 --- a/tools/correct_blake2b_and_md5_hashes_in_database.py +++ b/tools/correct_blake2b_and_md5_hashes_in_database.py @@ -6,7 +6,7 @@ import shutil import sys -from lib.database import Database +from lib.database_lib import Database from lib.database_lib.config import Config from lib.lorisgetopt import LorisGetOpt diff --git a/tools/correct_lists_incorrectly_saved_in_parameter_file.py b/tools/correct_lists_incorrectly_saved_in_parameter_file.py index 773d2cece..d9fc98602 100755 --- a/tools/correct_lists_incorrectly_saved_in_parameter_file.py +++ b/tools/correct_lists_incorrectly_saved_in_parameter_file.py @@ -2,7 +2,7 @@ import os -from lib.database import Database +from lib.database_lib import Database from lib.lorisgetopt import LorisGetOpt