froth-webdriverio-framework 1.0.96 → 1.0.98

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.
@@ -26,7 +26,7 @@ async function dbtype(jsondata) {
26
26
  connectionpool = mysqlconnect.connectToMySQL(jsondata.host, jsondata.username, jsondata.password, jsondata.schema_name, jsondata.port_number);
27
27
  break;
28
28
  case 'PostgreSQL':
29
- connectionpool = postgreSqlConnect.connectToPostgreSQL(jsondata.database_type,jsondata.host, jsondata.username, jsondata.password, jsondata.schema_name, jsondata.port_number);
29
+ connectionpool = await postgreSqlConnect.connectToPostgreSQL(jsondata.database_type,jsondata.host, jsondata.username, jsondata.password, jsondata.schema_name, jsondata.port_number);
30
30
  break;
31
31
  default:
32
32
  console.log('Unknown dbtype.');
@@ -4,22 +4,30 @@ const { Pool } = require('pg');
4
4
  async function connectToPostgreSQL(hostname, username, password, dbname, portnumber) {
5
5
  try {
6
6
  console.log('Connecting to the PostgreSQL database...');
7
- const poolConfig = new Pool({
8
- user: username,
7
+
8
+ const poolConfig = {
9
9
  host: hostname,
10
- database: dbname,
10
+ user: username,
11
11
  password: password,
12
- port: 5432,
13
- });
14
-
12
+ database: dbname,
13
+ port: portnumber // Increased connection timeout
14
+ };
15
+ // const poolConfig = new Pool({
16
+ // user: "postgres",
17
+ // host: "10.0.222.36",
18
+ // database: "testops",
19
+ // password: "A6b1b/b%V9",
20
+ // port: 5432,
21
+ // });
15
22
 
16
- const client = await poolConfig.connect();
17
- console.log('Connected to the database');
23
+ const pool = new Pool(poolConfig);
24
+ // const client = await poolConfig.connect();
25
+ console.log('PostgreSQL connection pool created.');
18
26
  // Optionally, run a simple query to verify the connection
19
- const res = await client.query('SELECT NOW()');
20
- console.log("postgresresults "+res.rows[0]);
21
- client.release();
22
-
27
+ // const res = await client.query('SELECT NOW()');
28
+ // console.log("postgresresults "+res.rows[0]);
29
+ // client.release();
30
+ return pool;
23
31
  } catch (error) {
24
32
  console.error('Error creating MySQL connection pool:', error);
25
33
  throw error;
@@ -33,12 +41,12 @@ async function fetchDataFromPostgresDB(connectionpool, query) {
33
41
  let finalResult = null;
34
42
  try {
35
43
  console.log("connectionpool" + connectionpool)
36
- connection = await connectionpool.getConnection();
44
+ connection = await connectionpool.connect();
37
45
 
38
- console.log('Connected to the MySQL database.' + connection);
46
+ console.log('Connected to the fetchDataFromPostgresDB database.' + connection);
39
47
 
40
- const [rows] = await connection.execute(query);
41
- const dataArray = rows;
48
+ const result = await connection.query(query);
49
+ const dataArray = result[0] || result.rows; // Adjust for MySQL and PostgreSQL response formats
42
50
  finalResult = {
43
51
  totalNumberOfRecords: dataArray.length,
44
52
  records: dataArray
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "froth-webdriverio-framework",
3
- "version": "1.0.96",
3
+ "version": "1.0.98",
4
4
  "readme": "WebdriverIO Integration",
5
5
  "description": "WebdriverIO and BrowserStack App Automate",
6
6
  "license": "MIT",