added organizational units

main
sasha 12 months ago
parent 8faf7b4d3e
commit 70c04d8f3f

@ -2,16 +2,24 @@ const fs = require('fs');
const path = require('path');
const mysql = require('mysql2/promise');
//Uncomment for Marco Server
// const pool = mysql.createPool({
// "host": "127.0.0.1",
// "port": 3306,
// "user": "rw",
// "password": "5Xk8Y7Kz6H3DeCXqcZ#Sb%Nz",
// "ssl": false
// });
//Uncomment for local test
const pool = mysql.createPool({
"host": "127.0.0.1",
"port": 3306,
"user": "rw",
"password": "5Xk8Y7Kz6H3DeCXqcZ#Sb%Nz",
"user": "root",
"password": "password",
"ssl": false
});
// Function to read JSON files recursively in a directory
function readJsonFiles(directory) {
const files = fs.readdirSync(directory);
@ -68,6 +76,20 @@ async function processJsonFile(filePath) {
}
}
//TODO: insert city_key into .tMRN_OU
try {
const otherDataString = JSON.stringify(otherData);
//MRN_HWPA for Marco server, mrnValUser on local
const query = 'INSERT INTO mrnValUser.tMRN_OU (M_DATA, M_OU, M_Flag, M_Name, M_Imprint, M_State) VALUES (?, ?, ?, ?, ?, ?);';
let res = await pool.execute(query, [otherDataString, data.city_key, "T", "test", "test", "test"]);
if (typeof res === 'undefined') {
throw new Error("Database connection error");
}
console.log('updated database with otherdata', res[0]);
} catch (err) {
console.log(err);
}
/*
try {
const otherDataString = JSON.stringify(otherData);
const query = 'UPDATE MRN_HWPA.tMRN_OU SET M_Data = ? WHERE M_OU = ?';
@ -79,6 +101,7 @@ async function processJsonFile(filePath) {
} catch (err) {
console.log(err);
}
*/
}
// Start processing JSON files in a directory

Loading…
Cancel
Save