Beispiel #1
0
 def print_table(self, writer, table):
     modules = table_dicts.table_module_dict(table)
     if table == 'Patient_Information_History':
         output_type = ask_y_n('Do you want a research print out for ' +
                               table + '?')
         if output_type:
             modules = table_dicts.table_module_research(table)
     columns = []
     if not modules:
         modules = 'no_modules'
         columns = table_dicts.db_dict(table, modules)
     else:
         for module in modules:
             cols = table_dicts.db_dict(table, module)
             columns = columns + cols
     if table != 'Block_list':
         col_list = table_dicts.create_col_list(columns)
     else:
         col_list = columns
     sql = ('SELECT ' + ", ".join(col_list) + " FROM '" + table + "'")
     df = pd.read_sql(sql, self.conn)
     number = df.shape[0]
     df.to_excel(writer,
                 sheet_name=table,
                 startrow=0,
                 index=False,
                 header=True)
     return number
Beispiel #2
0
def get_sql_data(file_number, conn, module, table):

    columns = []
    cols = table_dicts.db_dict(table, module)
    columns = columns + cols
    col_list = table_dicts.create_col_list(columns)
    sql = ('SELECT ' + ", ".join(col_list) + " FROM '" + str(table) +
           "' WHERE File_number = '" + file_number + "'")
    df = pd.read_sql(sql, conn)
    return df
Beispiel #3
0
    sql = "SELECT * FROM '" + index + "'"
    df_ = pd.read_sql(sql, conn_nutan)
    df_.to_sql(index, conn_all, index=False, if_exists="append")

file_rituja = 'PCCM_BreastCancerDB_all_data_rituja.db'
folders_rituja = 'D:/Documents/IISER/Prashanti_docs/QSync/RESEARCH/Clinical_Database/PCCM Clinical Data/2018/08/07'
path_rituja = os.path.join(folders_rituja, file_rituja)
conn_rituja = sqlite3.connect(path)
cursor_rituja = conn_rituja.cursor()
tables = [
    "Patient_Information_History", "Follow_up_Data", "HormoneTherapy_Survival",
    "Radiotherapy", "General_Medical_History", "Family_Cancer_History",
    'Previous_Cancer_History', 'Nutritional_Supplements', 'Physical_Activity',
    'Breast_Feeding'
]

modules = table_dicts.table_module_dict(table)
columns = []
if modules == []:
    columns = table_dicts.db_dict(table, modules)
else:
    for module in modules:
        cols = table_dicts.db_dict(table, module)
        columns = columns + cols
col_list = table_dicts.create_col_list(columns)
files = ['499/15', '657/16', '509/15']
for table in tables:
    for file in files:
        sql = "SELECT * FROM '" + table + "'"
        df_ = pd.read_sql(sql, conn_nutan)
        df_.to_sql(index, conn_all, index=False, if_exists="append")