froth-webdriverio-framework 1.0.90 → 1.0.92
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/getsuiteDetails.js +2 -2
- package/commonMethods/assertText.js +30 -0
- package/commonMethods/connectToDB.js +18 -11
- package/config/android.conf.js +2 -2
- package/config/commonconfig.js +1 -1
- package/config/ios.conf.js +5 -5
- package/config/web.conf.bs.js +8 -8
- package/db/mysqlOperations.js +73 -0
- package/db/postgresOperations.js +71 -0
- package/package.json +2 -1
- package/commonMethods/verifyText.js +0 -28
- package/db/dbconnections.js +0 -87
package/api/getsuiteDetails.js
CHANGED
|
@@ -24,14 +24,14 @@ async function getSuiteDetails(frothUrl, token, id) {
|
|
|
24
24
|
jsondata.test_data_id = data.test_data_id;
|
|
25
25
|
jsondata.browser_stack_urls = data.browser_stack_urls;
|
|
26
26
|
jsondata.automation_script_id=data.automation_script_id;
|
|
27
|
-
|
|
27
|
+
// console.log("automation_script_id:" + JSON.stringify(jsondata.automation_script_id))
|
|
28
28
|
const automationScripts = jsondata.automation_script_id.reduce((obj, item) => {
|
|
29
29
|
obj[item.automation_script_id] = item.automation_script_id;
|
|
30
30
|
BUFFER.setItem(item.automation_script_name, item.id);
|
|
31
31
|
return obj;
|
|
32
32
|
}, {});
|
|
33
33
|
jsondata.test_sequence = data.test_sequence;
|
|
34
|
-
|
|
34
|
+
// console.log("automation_script_ details:" + JSON.stringify(BUFFER))
|
|
35
35
|
|
|
36
36
|
// console.log("json data :" + JSON.stringify(jsondata));
|
|
37
37
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Function to verify text in Android app
|
|
2
|
+
async function verifyText(driver, elementSelector, expectedText) {
|
|
3
|
+
// try {
|
|
4
|
+
// Wait for the element to be visible
|
|
5
|
+
await driver.waitUntil(async () => {
|
|
6
|
+
const element = await driver.$(elementSelector);
|
|
7
|
+
return await element.isDisplayed();
|
|
8
|
+
}, { timeout: 30000});
|
|
9
|
+
|
|
10
|
+
// Get the actual text from the element
|
|
11
|
+
const element = await driver.$(elementSelector);
|
|
12
|
+
const actualText = await element.getText();
|
|
13
|
+
|
|
14
|
+
expect(actualText).toEqual(expectedText,`Expected title to be "${expectedText}", but found "${actualText}"`);
|
|
15
|
+
|
|
16
|
+
// // Compare the actual text with the expected text
|
|
17
|
+
// if (actualText === expectedText) {
|
|
18
|
+
// console.log('Text verification passed. Actual text:', actualText, 'Expected text:', expectedText);
|
|
19
|
+
// return true;
|
|
20
|
+
// } else {
|
|
21
|
+
// console.warn('Text verification failed. Actual text:', actualText, 'Expected text:', expectedText);
|
|
22
|
+
// }
|
|
23
|
+
// } catch (error) {
|
|
24
|
+
// console.error('Error occurred while verifying text:', error);
|
|
25
|
+
// }
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
module.exports = verifyText;
|
|
29
|
+
|
|
30
|
+
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
const dbinfo = require('../api/getDBdetails');
|
|
3
|
-
const
|
|
3
|
+
const mysqlconnect = require('../db/mysqlOperations');
|
|
4
|
+
const postgreSqlConnect = require('../db/postgresOperations');
|
|
4
5
|
const getLoginToken = require('../api/loginapi');
|
|
5
6
|
// const { LocalStorage } = require('node-localstorage');
|
|
6
7
|
// global.BUFFER = new LocalStorage('./storage');
|
|
@@ -8,22 +9,24 @@ const getLoginToken = require('../api/loginapi');
|
|
|
8
9
|
async function connectToDB(id, querytype, query) {
|
|
9
10
|
try {
|
|
10
11
|
const jsondata = await dbinfo.getDbDetails(BUFFER.getItem("ORGANISATION_DOMAIN_URL"), BUFFER.getItem("LOGIN_TOKEN"), id);
|
|
11
|
-
let connectionpool = await dbtype(jsondata
|
|
12
|
-
let result = await executeQuery(querytype, query, connectionpool);
|
|
12
|
+
let connectionpool = await dbtype(jsondata);
|
|
13
|
+
let result = await executeQuery(jsondata.database_type,querytype, query, connectionpool);
|
|
13
14
|
return result;
|
|
14
15
|
} catch (error) {
|
|
15
16
|
console.error('Error connectToDB', error);
|
|
16
17
|
}
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
async function dbtype(
|
|
20
|
+
async function dbtype(jsondata) {
|
|
20
21
|
let connectionpool;
|
|
21
22
|
try {
|
|
22
|
-
switch (
|
|
23
|
+
switch (jsondata.database_type) {
|
|
23
24
|
case 'MySQL':
|
|
24
|
-
connectionpool =
|
|
25
|
+
connectionpool = mysqlconnect.connectToMySQL(jsondata.host, jsondata.username, jsondata.password, jsondata.schema_name, jsondata.port_number);
|
|
26
|
+
break;
|
|
27
|
+
case 'PostgreSQL':
|
|
28
|
+
connectionpool = postgreSqlConnect.connectToPostgreSQL(jsondata.database_type,jsondata.host, jsondata.username, jsondata.password, jsondata.schema_name, jsondata.port_number);
|
|
25
29
|
break;
|
|
26
|
-
|
|
27
30
|
default:
|
|
28
31
|
console.log('Unknown dbtype.');
|
|
29
32
|
|
|
@@ -34,18 +37,22 @@ async function dbtype(type, jsondata) {
|
|
|
34
37
|
}
|
|
35
38
|
|
|
36
39
|
|
|
37
|
-
async function executeQuery(querytype, query, connectionpool) {
|
|
40
|
+
async function executeQuery(datatype,querytype, query, connectionpool) {
|
|
38
41
|
let finalResult;
|
|
39
42
|
try {
|
|
40
43
|
switch (querytype) {
|
|
41
44
|
case 'select':
|
|
42
|
-
|
|
45
|
+
if (datatype === 'MySQL') {
|
|
46
|
+
finalResult = mysqlconnect.fetchDataFromDB(connectionpool, query);
|
|
47
|
+
}else if(datatype === 'PostgreSQL'){
|
|
48
|
+
finalResult = postgreSqlConnect.fetchDataFromPostgresDB(connectionpool, query);
|
|
49
|
+
}
|
|
43
50
|
break;
|
|
44
51
|
case 'insert':
|
|
45
|
-
|
|
52
|
+
// connectionpool = mysqlconnect.connectTomysql(jsondata.hostname, jsondata.username, jsondata.password, jsondata.dbname, jsondata.portnumber);
|
|
46
53
|
break;
|
|
47
54
|
case 'update':
|
|
48
|
-
|
|
55
|
+
// connectionpool = postgreSqlConnect.fetchDataFromPostgresDB(jsondata.hostname, jsondata.username, jsondata.password, jsondata.dbname, jsondata.portnumber);
|
|
49
56
|
break;
|
|
50
57
|
default:
|
|
51
58
|
console.log('Unknown querytype.');
|
package/config/android.conf.js
CHANGED
|
@@ -9,7 +9,7 @@ const androidConfig = deepmerge.all([commonmobileconfig, {
|
|
|
9
9
|
[
|
|
10
10
|
'browserstack',
|
|
11
11
|
{
|
|
12
|
-
|
|
12
|
+
// testObservability: true,
|
|
13
13
|
// buildName: "ANDROID BUILD",
|
|
14
14
|
// buildIdentifier: "ANDROID BUILD_" + process.env.BUILD_NUMBER,
|
|
15
15
|
browserstackLocal: process.env.BROWSERSTACK_LOCAL || false,
|
|
@@ -26,7 +26,7 @@ const androidConfig = deepmerge.all([commonmobileconfig, {
|
|
|
26
26
|
platformVersion: process.env.OSVERSION,
|
|
27
27
|
platformName: 'android',
|
|
28
28
|
interactiveDebugging: true,
|
|
29
|
-
buildName: process.env.BROWSERSTACK_BUILD_NAME || '
|
|
29
|
+
buildName: process.env.BROWSERSTACK_BUILD_NAME || 'Android_Build',
|
|
30
30
|
|
|
31
31
|
}
|
|
32
32
|
}],
|
package/config/commonconfig.js
CHANGED
|
@@ -90,7 +90,7 @@ const commonconfig = {
|
|
|
90
90
|
scriptresult = "FAILED"
|
|
91
91
|
}
|
|
92
92
|
console.log('---------------------------------------');
|
|
93
|
-
await exeDetails.updateScriptExecutionStatus(BUFFER.getItem("ORGANISATION_DOMAIN_URL"), BUFFER.getItem("LOGIN_TOKEN"),
|
|
93
|
+
await exeDetails.updateScriptExecutionStatus(BUFFER.getItem("ORGANISATION_DOMAIN_URL"), BUFFER.getItem("LOGIN_TOKEN"), scriptid,scriptresult)
|
|
94
94
|
|
|
95
95
|
},
|
|
96
96
|
/**
|
package/config/ios.conf.js
CHANGED
|
@@ -6,12 +6,12 @@ const iosconfig = deepmerge.all([commonmobileconfig, {
|
|
|
6
6
|
[
|
|
7
7
|
'browserstack',
|
|
8
8
|
{
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
browserstackLocal: false,
|
|
9
|
+
// testObservability: true,
|
|
10
|
+
// buildIdentifier: `#${process.env.BUILD_NUMBER}`,
|
|
11
|
+
browserstackLocal: process.env.BROWSERSTACK_LOCAL || false,
|
|
12
12
|
opts: {
|
|
13
13
|
forcelocal: false,
|
|
14
|
-
|
|
14
|
+
// localIdentifier: "webdriverio-appium"
|
|
15
15
|
},
|
|
16
16
|
app: process.env.BROWSERSTACK_APP_PATH || 'bs://d6588d0899a2ac5c485d4784af9ad28d06b98c44'
|
|
17
17
|
}
|
|
@@ -24,7 +24,7 @@ const iosconfig = deepmerge.all([commonmobileconfig, {
|
|
|
24
24
|
osVersion: process.env.OSVERSION || "17",
|
|
25
25
|
platformName: 'iOS',
|
|
26
26
|
interactiveDebugging: true,
|
|
27
|
-
buildName: process.env.BROWSERSTACK_BUILD_NAME || '
|
|
27
|
+
buildName: process.env.BROWSERSTACK_BUILD_NAME || 'IOS_Build',
|
|
28
28
|
|
|
29
29
|
}
|
|
30
30
|
}],
|
package/config/web.conf.bs.js
CHANGED
|
@@ -15,14 +15,14 @@ const webbsconfig = deepmerge.all([commonconfig, {
|
|
|
15
15
|
|
|
16
16
|
services: [
|
|
17
17
|
['browserstack', {
|
|
18
|
-
|
|
19
|
-
testObservabilityOptions: {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
},
|
|
18
|
+
// testObservability: true,
|
|
19
|
+
// testObservabilityOptions: {
|
|
20
|
+
// // user: 'prabathkumar_qavxGX' || process.env.BROWSERSTACK_USERNAME,
|
|
21
|
+
// // key: 'RvqEi62rhwa5QwGJtweZ' || process.env.BROWSERSTACK_ACCESS_KEY,
|
|
22
|
+
// projectName: process.env.PROJECTNAME || "roboticodigital",
|
|
23
|
+
// // buildName: 'WEB BUILD',
|
|
24
|
+
// buildTag: 'WEB BUILD',
|
|
25
|
+
// },
|
|
26
26
|
}]
|
|
27
27
|
],
|
|
28
28
|
// ====================
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
const mysql = require('mysql2/promise');
|
|
2
|
+
const { Pool } = require('pg');
|
|
3
|
+
|
|
4
|
+
// Function to establish connection to MySQL database
|
|
5
|
+
async function connectToMySQL(hostname, username, password, dbname, portnumber) {
|
|
6
|
+
try {
|
|
7
|
+
const poolConfig = {
|
|
8
|
+
host: hostname,
|
|
9
|
+
user: username,
|
|
10
|
+
password: password,
|
|
11
|
+
database: dbname,
|
|
12
|
+
port: portnumber,
|
|
13
|
+
waitForConnections: true,
|
|
14
|
+
connectionLimit: 10,
|
|
15
|
+
queueLimit: 0
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
let pool = mysql.createPool(poolConfig);
|
|
20
|
+
console.log('MySQL connection pool created.');
|
|
21
|
+
return pool;
|
|
22
|
+
} catch (error) {
|
|
23
|
+
console.error('Error creating MySQL connection pool:', error);
|
|
24
|
+
throw error;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
// Function to fetch data from the database
|
|
30
|
+
async function fetchDataFromDB(connectionpool, query) {
|
|
31
|
+
let connection = null;
|
|
32
|
+
let finalResult = null;
|
|
33
|
+
try {
|
|
34
|
+
console.log("connectionpool" + connectionpool)
|
|
35
|
+
connection = await connectionpool.getConnection();
|
|
36
|
+
|
|
37
|
+
console.log('Connected to the MySQL database.' + connection);
|
|
38
|
+
|
|
39
|
+
const [rows] = await connection.execute(query);
|
|
40
|
+
const dataArray = rows;
|
|
41
|
+
finalResult = {
|
|
42
|
+
totalNumberOfRecords: dataArray.length,
|
|
43
|
+
records: dataArray
|
|
44
|
+
};
|
|
45
|
+
console.log(JSON.stringify(finalResult, null, 2));
|
|
46
|
+
} catch (error) {
|
|
47
|
+
console.error('Error fetching data:', error);
|
|
48
|
+
} finally {
|
|
49
|
+
if (connection) {
|
|
50
|
+
connection.release();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return finalResult;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Main function to call the database connection and fetch data
|
|
57
|
+
// async function main() {
|
|
58
|
+
// try {
|
|
59
|
+
// const connection = await connectToMySQL('10.0.0.6', 'root', 'password123', 'power_seraya_step', 3406);
|
|
60
|
+
// console.log('Connection pool created.' + connection);
|
|
61
|
+
// const query = 'SELECT id,EventID,NoPlate FROM store_images limit 2';
|
|
62
|
+
// await fetchDataFromDB(connection, query);
|
|
63
|
+
// } catch (err) {
|
|
64
|
+
// console.log('Error connecting to database:', err.stack);
|
|
65
|
+
// }
|
|
66
|
+
// }
|
|
67
|
+
|
|
68
|
+
// main();
|
|
69
|
+
|
|
70
|
+
module.exports = {
|
|
71
|
+
connectToMySQL,
|
|
72
|
+
fetchDataFromDB
|
|
73
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const { Pool } = require('pg');
|
|
2
|
+
|
|
3
|
+
// Function to establish connection to PostgreSQL database
|
|
4
|
+
async function connectToPostgreSQL(hostname, username, password, dbname, portnumber) {
|
|
5
|
+
const poolConfig = {
|
|
6
|
+
host: hostname,
|
|
7
|
+
user: username,
|
|
8
|
+
password: password,
|
|
9
|
+
database: dbname,
|
|
10
|
+
port: portnumber,
|
|
11
|
+
max: 10,
|
|
12
|
+
idleTimeoutMillis: 60000,
|
|
13
|
+
connectionTimeoutMillis: 60000,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
const pool = new Pool(poolConfig);
|
|
18
|
+
console.log('PostgreSQL connection pool created.');
|
|
19
|
+
return pool;
|
|
20
|
+
} catch (error) {
|
|
21
|
+
console.error('Error creating PostgreSQL connection pool:', error);
|
|
22
|
+
throw error;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Function to fetch data from the database
|
|
27
|
+
async function fetchDataFromPostgresDB(connectionpool, query) {
|
|
28
|
+
let connection = null;
|
|
29
|
+
let finalResult = null;
|
|
30
|
+
try {
|
|
31
|
+
|
|
32
|
+
connection = await connectionpool.connect();
|
|
33
|
+
console.log('Connected to the PostgreSQL database.' + connection);
|
|
34
|
+
const result = await connection.query(query);
|
|
35
|
+
const dataArray = result.rows; // Adjust for MySQL and PostgreSQL response formats
|
|
36
|
+
|
|
37
|
+
finalResult = {
|
|
38
|
+
totalNumberOfRecords: dataArray.length,
|
|
39
|
+
records: dataArray
|
|
40
|
+
};
|
|
41
|
+
console.log(JSON.stringify(finalResult, null, 2));
|
|
42
|
+
} catch (error) {
|
|
43
|
+
console.error('Error fetching data:', error);
|
|
44
|
+
} finally {
|
|
45
|
+
if (connection) {
|
|
46
|
+
|
|
47
|
+
connection.release();
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return finalResult;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Main function to call the database connection and fetch data
|
|
55
|
+
// async function main() {
|
|
56
|
+
// try {
|
|
57
|
+
// const connection = await connectToPostgreSQL('10.0.222.36', 'postgres', 'A6b1b/b%V9', 'testops', 5432);
|
|
58
|
+
// console.log('Connection pool created.' + connection);
|
|
59
|
+
// const query = 'SELECT planned_effort,project_type,project_name FROM public.account_project_details';
|
|
60
|
+
// await fetchDataFromPostgresDB(connection, query);
|
|
61
|
+
// } catch (err) {
|
|
62
|
+
// console.log('Error connecting to database:', err.stack);
|
|
63
|
+
// }
|
|
64
|
+
// }
|
|
65
|
+
|
|
66
|
+
// main();
|
|
67
|
+
|
|
68
|
+
module.exports = {
|
|
69
|
+
connectToPostgreSQL,
|
|
70
|
+
fetchDataFromPostgresDB
|
|
71
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "froth-webdriverio-framework",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.92",
|
|
4
4
|
"readme": "WebdriverIO Integration",
|
|
5
5
|
"description": "WebdriverIO and BrowserStack App Automate",
|
|
6
6
|
"license": "MIT",
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"mysql2": "^3.10.2",
|
|
40
40
|
"node-fetch": "^3.3.2",
|
|
41
41
|
"node-localstorage": "^3.0.5",
|
|
42
|
+
"pg": "^8.12.0",
|
|
42
43
|
"ts-node": "^10.9.2",
|
|
43
44
|
"typescript": "^5.4.5"
|
|
44
45
|
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
// Function to verify text in Android app
|
|
2
|
-
async function verifyText(driver, elementSelector, expectedText) {
|
|
3
|
-
try {
|
|
4
|
-
// Wait for the element to be visible
|
|
5
|
-
await driver.waitUntil(async () => {
|
|
6
|
-
const element = await driver.$(elementSelector);
|
|
7
|
-
return await element.isDisplayed();
|
|
8
|
-
}, { timeout: 30000});
|
|
9
|
-
|
|
10
|
-
// Get the actual text from the element
|
|
11
|
-
const element = await driver.$(elementSelector);
|
|
12
|
-
const actualText = await element.getText();
|
|
13
|
-
|
|
14
|
-
// Compare the actual text with the expected text
|
|
15
|
-
if (actualText === expectedText) {
|
|
16
|
-
console.log('Text verification passed. Actual text:', actualText, 'Expected text:', expectedText);
|
|
17
|
-
return true;
|
|
18
|
-
} else {
|
|
19
|
-
console.warn('Text verification failed. Actual text:', actualText, 'Expected text:', expectedText);
|
|
20
|
-
}
|
|
21
|
-
} catch (error) {
|
|
22
|
-
console.error('Error occurred while verifying text:', error);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
module.exports = verifyText;
|
|
27
|
-
|
|
28
|
-
|
package/db/dbconnections.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
const mysql = require('mysql2/promise');
|
|
2
|
-
|
|
3
|
-
// Function to establish connection to MySQL database
|
|
4
|
-
async function connectTomysql(hostname, username, password, dbname, portnumber) {
|
|
5
|
-
try {
|
|
6
|
-
const poolConfig = {
|
|
7
|
-
host: hostname, // Replace with your database host
|
|
8
|
-
user: username, // Replace with your database username
|
|
9
|
-
password: password, // Replace with your database password
|
|
10
|
-
database: dbname,
|
|
11
|
-
port: portnumber,
|
|
12
|
-
waitForConnections: true,
|
|
13
|
-
connectionLimit: 10, // Adjust the number of connections in the pool
|
|
14
|
-
queueLimit: 0 // Replace with your database name
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
try {
|
|
18
|
-
const pool = mysql.createPool(poolConfig);
|
|
19
|
-
console.log('Connection pool created.');
|
|
20
|
-
return pool;
|
|
21
|
-
} catch (error) {
|
|
22
|
-
console.error('Error creating connection pool:', error);
|
|
23
|
-
throw error;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
} catch (err) {
|
|
27
|
-
console.log('Error connecting to database:', err.stack);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
async function fetchDataFromDB(connectionpool, query) {
|
|
32
|
-
let connection = null;
|
|
33
|
-
let finalResult = null;
|
|
34
|
-
try {
|
|
35
|
-
connection = await connectionpool.getConnection();
|
|
36
|
-
console.log('Connected to the MySQL database.');
|
|
37
|
-
|
|
38
|
-
// Execute the query to fetch all data
|
|
39
|
-
const [rows] = await connection.execute(query);
|
|
40
|
-
|
|
41
|
-
// Store the data into an array
|
|
42
|
-
const dataArray = rows;
|
|
43
|
-
let recordsArray = [];
|
|
44
|
-
console.log("data is " + JSON.stringify(dataArray, null, 2));
|
|
45
|
-
// Print the values for each column in each row
|
|
46
|
-
// dataArray.forEach(row => {
|
|
47
|
-
// let record = {};
|
|
48
|
-
// Object.keys(row).forEach(columnName => {
|
|
49
|
-
// console.log(`${columnName}: ${row[columnName]}`);
|
|
50
|
-
// record[columnName] = row[columnName];
|
|
51
|
-
// // BUFFER.setItem(columnName, row[columnName]);
|
|
52
|
-
// });
|
|
53
|
-
// console.log('---'); // Separator for each row
|
|
54
|
-
// });
|
|
55
|
-
|
|
56
|
-
finalResult = {
|
|
57
|
-
totalNumberOfRecords: dataArray.length,
|
|
58
|
-
records: dataArray
|
|
59
|
-
};
|
|
60
|
-
console.log(JSON.stringify(finalResult, null, 2));
|
|
61
|
-
|
|
62
|
-
} catch (error) {
|
|
63
|
-
console.error('Error fetching data:', error);
|
|
64
|
-
} finally {
|
|
65
|
-
connection.release();
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
return finalResult;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// write main method to call the functions
|
|
72
|
-
|
|
73
|
-
// async function main() {
|
|
74
|
-
// try {
|
|
75
|
-
// const connection = await connectTomysql('10.0.0.6', 'root', 'password123', 'power_seraya_step', 3406);
|
|
76
|
-
// const query = 'SELECT id,EventID,NoPlate FROM store_images limit 2';
|
|
77
|
-
// await fetchDataFromDB(connection, query);
|
|
78
|
-
// } catch (err) {
|
|
79
|
-
// console.log('Error connecting to database:', err.stack);
|
|
80
|
-
// }
|
|
81
|
-
// }
|
|
82
|
-
|
|
83
|
-
// main()
|
|
84
|
-
module.exports = {
|
|
85
|
-
connectTomysql,
|
|
86
|
-
fetchDataFromDB
|
|
87
|
-
};
|