From 926fc29d445eef0d0ffd369e5d20a9f08601f806 Mon Sep 17 00:00:00 2001 From: JeffreyMinucci Date: Fri, 31 Jan 2025 12:06:28 -0500 Subject: [PATCH] update db upload documentation --- database/DATA_INITIALIZATION.md | 12 +++++++++--- database/ms1_batch_search_table_ddl.sql | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/database/DATA_INITIALIZATION.md b/database/DATA_INITIALIZATION.md index ae269b9..c9be6b8 100644 --- a/database/DATA_INITIALIZATION.md +++ b/database/DATA_INITIALIZATION.md @@ -3,7 +3,7 @@ The four steps listed below are required to initialize the database and configur # Table Creation The application is currently set up to work with a PostGreSQL database. Run the DDL in _ms1_batch_search_table_ddl.sql_ -to create the table and properly index it. +to create the table and properly index it. If the table already exists be sure to back it up somewhere. $ psql -h %host -p $port --dbname %databaseName --user %username < ms1_batch_search_table_ddl.sql @@ -17,10 +17,16 @@ associated with the %username input in the command. If you would like the data $ mysql -h mysql-ip-m.epa.gov -u %username -p prod_dsstox ms1_data.tsv # Data Upload -Login into PostGreSQL instance that will be used to service the nta_flask application. Run the following command at +Login into PostGreSQL instance that will be used to service the nta_flask application. + +Run the following command at postgres command line prompt while in the database intended for use. - # \COPY ms1_batch_search (msr_dsstox_compound_id, msr_monoisotopic_mass,msr_smiles,msr_mol_formula, dsstox_substance_id,preferred_name,casrn,jchem_inchi_key,acd_iupac_name,mol_formula,monoisotopic_mass,total_median,expocast_comptox_link,nhanes_comptox_link,assay_count_active,assay_count_total) from '%path2File' with delimiter E'\t' null as 'NULL' csv header + # \COPY ms1_batch_search (msr_dsstox_compound_id, msr_monoisotopic_mass,msr_smiles,msr_mol_formula, dsstox_substance_id,preferred_name,casrn,jchem_inchi_key,acd_iupac_name,mol_formula,monoisotopic_mass,total_median,expocast_comptox_link,nhanes_comptox_link,assay_count_active,assay_count_total,data_sources) from '%path2File' with delimiter E'\t' null as 'NA' csv header + +Then grant the 'ntauser' read-only access to the new table. + + GRANT SELECT ON ms1_batch_search to ntauser; diff --git a/database/ms1_batch_search_table_ddl.sql b/database/ms1_batch_search_table_ddl.sql index f1d8a02..b85afb1 100644 --- a/database/ms1_batch_search_table_ddl.sql +++ b/database/ms1_batch_search_table_ddl.sql @@ -7,7 +7,7 @@ CREATE TABLE ms1_batch_search ( msr_smiles TEXT NULL, msr_mol_formula VARCHAR(255) NULL, dsstox_substance_id VARCHAR(45) NULL, - preferred_name VARCHAR(255) NULL, + preferred_name TEXT NULL, casrn VARCHAR(45) NULL, jchem_inchi_key VARCHAR(45) NULL, acd_iupac_name TEXT NULL,