diff --git a/Week2/assignment-w2/createTables.js b/Week2/assignment-w2/createTables.js new file mode 100644 index 000000000..7cd269dca --- /dev/null +++ b/Week2/assignment-w2/createTables.js @@ -0,0 +1,138 @@ +import { Client } from "pg"; +import { authors, researches, researchAuthors } from "./data.js"; +import { dbName } from "./database.js"; + +const config = { + host: "localhost", + port: 5432, + user: "hyfuser", + password: "hyfpassword", + database: dbName, +}; + +const client = new Client(config); + +async function seedDatabase() { + const CREATE_AUTHORS_TABLE = ` + CREATE TABLE IF NOT EXISTS authors ( + author_id SERIAL PRIMARY KEY, + author_name VARCHAR(100), + university VARCHAR(100), + date_of_birth DATE, + h_index INTEGER, + gender VARCHAR(1) CHECK (gender IN ('m', 'f')) + ); + `; + + const ADD_MENTOR_COLUMN = ` + ALTER TABLE authors + ADD COLUMN mentor INTEGER; + ALTER TABLE authors + ADD CONSTRAINT fk_mentor + FOREIGN KEY (mentor) REFERENCES authors(author_id); +`; + + const CREATE_RESEARCH_PAPERS = ` + CREATE TABLE IF NOT EXISTS research_papers ( + paper_id SERIAL PRIMARY KEY, + paper_title VARCHAR(300), + conference VARCHAR(300), + publish_date DATE, + published BOOLEAN DEFAULT false + ); + `; + + const CREATE_RESEARCH_AUTHORS = ` + CREATE TABLE IF NOT EXISTS research_authors ( + author_id INTEGER, + paper_id INTEGER, + PRIMARY KEY (author_id, paper_id), + FOREIGN KEY (author_id) REFERENCES authors(author_id), + FOREIGN KEY (paper_id) REFERENCES research_papers(paper_id) + ); + `; + + try { + await client.connect(); + console.log("Connected to PostgreSQL database!"); + + await client.query("DROP TABLE IF EXISTS research_authors CASCADE;"); + + await client.query("DROP TABLE IF EXISTS research_papers CASCADE;"); + + await client.query("DROP TABLE IF EXISTS authors CASCADE;"); + + await client.query(CREATE_AUTHORS_TABLE); + console.log("Authors table created successfully"); + + await client.query(ADD_MENTOR_COLUMN); + console.log("Mentor column added to authors table"); + console.log("Authors table altered successfully"); + + await client.query(CREATE_RESEARCH_PAPERS); + console.log("Research Papers table created successfully"); + + await client.query(CREATE_RESEARCH_AUTHORS); + console.log("Research Authors table created successfully"); + + for (const author of authors) { + const insertQuery = ` + INSERT INTO authors(author_name, university, date_of_birth, h_index, gender, mentor) + VALUES ($1, $2, $3, $4, $5, NULL) + `; + const values = [ + author.author_name, + author.university, + author.date_of_birth, + author.h_index, + author.gender, + ]; + await client.query(insertQuery, values); + console.log(`Inserted author: ${author.author_name}`); + + //if author has mentor then update the table and add it + if (author.mentor !== null) { + const updateQuery = ` + UPDATE authors + SET mentor = $1 + WHERE author_name = $2 + `; + await client.query(updateQuery, [author.mentor, author.author_name]); + console.log(`Updated mentor for: ${author.author_name}`); + } + } + + for (const research of researches) { + const insertQuery = ` + INSERT INTO research_papers(paper_title, conference, publish_date, published) + VALUES ($1, $2, $3, $4) + `; + const values = [ + research.paper_title, + research.conference, + research.publish_date, + research.published, + ]; + await client.query(insertQuery, values); + console.log(`Inserted research paper: ${research.paper_title}`); + } + + for (const ele of researchAuthors) { + const insertQuery = ` + INSERT INTO research_authors(author_id, paper_id) + VALUES ($1, $2) + `; + const values = [ele.author_id, ele.paper_id]; + await client.query(insertQuery, values); + console.log(`Linked author ${ele.author_id} to paper ${ele.paper_id}.`); + } + + console.log("Database seeded successfully!"); + } catch (error) { + console.error("Error seeding database:", error); + } finally { + await client.end(); + } +} + +seedDatabase(); diff --git a/Week2/assignment-w2/data.js b/Week2/assignment-w2/data.js new file mode 100644 index 000000000..beb6d5080 --- /dev/null +++ b/Week2/assignment-w2/data.js @@ -0,0 +1,330 @@ +export const authors = [ + { + author_name: "Ali Hassan", + university: "University of Amsterdam", + date_of_birth: "1970-04-19", + h_index: 26, + gender: "f", + mentor: null, + }, + { + author_name: "Fatima Al-Sayed", + university: "Leiden University", + date_of_birth: "1993-07-04", + h_index: 45, + gender: "f", + mentor: null, + }, + { + author_name: "Omar Khalid", + university: "Radboud University", + date_of_birth: "1970-08-01", + h_index: 10, + gender: "m", + mentor: null, + }, + { + author_name: "Noor Abdullah", + university: "Leiden University", + date_of_birth: "1972-01-22", + h_index: 45, + gender: "m", + mentor: null, + }, + { + author_name: "Lina Abdulrahman", + university: "Utrecht University", + date_of_birth: "1967-03-15", + h_index: 21, + gender: "m", + mentor: null, + }, + { + author_name: "Hassan Al-Mansoor", + university: "Vrije Universiteit Amsterdam", + date_of_birth: "1984-11-04", + h_index: 41, + gender: "m", + mentor: null, + }, + { + author_name: "Rami Al-Khalifa", + university: "Radboud University", + date_of_birth: "1968-10-08", + h_index: 32, + gender: "m", + mentor: null, + }, + { + author_name: "Aisha Al-Harbi", + university: "Eindhoven University of Technology", + date_of_birth: "1978-10-24", + h_index: 53, + gender: "m", + mentor: 3, + }, + { + author_name: "Khaled Youssef", + university: "Leiden University", + date_of_birth: "1978-10-18", + h_index: 41, + gender: "f", + mentor: 2, + }, + { + author_name: "Yasmin Ahmed", + university: "TU Delft", + date_of_birth: "1994-12-28", + h_index: 50, + gender: "f", + mentor: 1, + }, + { + author_name: "Mariam Al-Farsi", + university: "Vrije Universiteit Amsterdam", + date_of_birth: "1987-08-23", + h_index: 13, + gender: "m", + mentor: 1, + }, + { + author_name: "Saad Al-Haddad", + university: "University of Groningen", + date_of_birth: "1970-08-26", + h_index: 39, + gender: "m", + mentor: 10, + }, + { + author_name: "Salma Al-Zayani", + university: "Vrije Universiteit Amsterdam", + date_of_birth: "1978-02-04", + h_index: 54, + gender: "m", + mentor: 12, + }, + { + author_name: "Zahra Al-Mutairi", + university: "Vrije Universiteit Amsterdam", + date_of_birth: "1970-09-15", + h_index: 41, + gender: "f", + mentor: null, + }, + { + author_name: "Mahmoud Al-Najjar", + university: "University of Groningen", + date_of_birth: "1983-09-20", + h_index: 38, + gender: "f", + mentor: null, + }, +]; + +export const researches = [ + { + paper_title: "Machine Learning Approaches for Medical Image Diagnosis", + conference: "ICML Amsterdam", + publish_date: "2019-06-12", + published: true, + }, + { + paper_title: "Deep Neural Networks for Brain Tumor Detection", + conference: "NeurIPS", + publish_date: "2020-12-04", + published: true, + }, + { + paper_title: "AI-Driven Smart Cities: A Case Study in Rotterdam", + conference: "IEEE SmartTech Rotterdam", + publish_date: "2021-05-18", + published: true, + }, + { + paper_title: "Optimizing Renewable Energy with Predictive Analytics", + conference: "EU Energy Summit", + publish_date: "2022-03-09", + published: true, + }, + { + paper_title: "Natural Language Processing in Arabic Social Media", + conference: null, + publish_date: null, + published: false, + }, + { + paper_title: "Autonomous Vehicle Safety Using Hybrid AI Models", + conference: "ICRA", + publish_date: "2021-09-14", + published: true, + }, + { + paper_title: "Quantum Computing Patterns for Large Data", + conference: "QTech Leiden", + publish_date: "2023-04-22", + published: true, + }, + { + paper_title: "Improving Cybersecurity with Graph-Based AI", + conference: "CyberSec Utrecht", + publish_date: "2018-10-10", + published: true, + }, + { + paper_title: "Artificial Intelligence in Dutch Healthcare", + conference: "HealthAI Amsterdam", + publish_date: "2020-02-15", + published: true, + }, + { + paper_title: "Predicting Student Performance with Machine Learning", + conference: null, + publish_date: null, + published: false, + }, + { + paper_title: "Arabic Handwriting Recognition Using CNNs", + conference: "ICDAR Qatar", + publish_date: "2021-07-17", + published: true, + }, + { + paper_title: "Climate Change Forecasting with AI Models", + conference: "ClimateTech Brussels", + publish_date: "2019-04-29", + published: true, + }, + { + paper_title: "Blockchain for Secure Medical Data Sharing", + conference: "MedTech Europe", + publish_date: "2023-01-09", + published: true, + }, + { + paper_title: "A Survey on Reinforcement Learning in Robotics", + conference: null, + publish_date: null, + published: false, + }, + { + paper_title: "AI-Based Early Warning Systems for Epidemics", + conference: "WHO Health Informatics Summit", + publish_date: "2020-08-03", + published: true, + }, + { + paper_title: "Cross-Lingual Language Models for Low-Resource Arabic", + conference: null, + publish_date: null, + published: false, + }, + { + paper_title: "Anomaly Detection in Financial Transactions", + conference: "FinTech Europe", + publish_date: "2018-03-06", + published: true, + }, + { + paper_title: "Generative Models for Art and Creative Industries", + conference: "CreativeAI Amsterdam", + publish_date: "2022-11-29", + published: true, + }, + { + paper_title: "Data-Driven Agriculture Monitoring in the Netherlands", + conference: "AgriTech Delft", + publish_date: "2021-10-01", + published: true, + }, + { + paper_title: "AI Ethics and Fairness in Government Systems", + conference: null, + publish_date: null, + published: false, + }, +]; + +export const researchAuthors = [ + // paper 1 + { author_id: 1, paper_id: 1 }, + { author_id: 2, paper_id: 1 }, + { author_id: 3, paper_id: 1 }, + + // paper 2 + { author_id: 2, paper_id: 2 }, + { author_id: 4, paper_id: 2 }, + { author_id: 5, paper_id: 2 }, + + // paper 3 + { author_id: 3, paper_id: 3 }, + { author_id: 6, paper_id: 3 }, + + // paper 4 + { author_id: 8, paper_id: 4 }, + + // paper 5 + { author_id: 5, paper_id: 5 }, + { author_id: 9, paper_id: 5 }, + + // paper 6 + { author_id: 6, paper_id: 6 }, + { author_id: 10, paper_id: 6 }, + { author_id: 11, paper_id: 6 }, + + // paper 7 + { author_id: 7, paper_id: 7 }, + { author_id: 12, paper_id: 7 }, + + // paper 8 + { author_id: 8, paper_id: 8 }, + { author_id: 13, paper_id: 8 }, + { author_id: 14, paper_id: 8 }, + + // paper 9 + { author_id: 9, paper_id: 9 }, + { author_id: 15, paper_id: 9 }, + + // paper 10 + { author_id: 1, paper_id: 10 }, + { author_id: 10, paper_id: 10 }, + + // paper 11 + { author_id: 2, paper_id: 11 }, + { author_id: 11, paper_id: 11 }, + + // paper 12 + { author_id: 3, paper_id: 12 }, + { author_id: 12, paper_id: 12 }, + + // paper 13 + { author_id: 4, paper_id: 13 }, + { author_id: 13, paper_id: 13 }, + + // paper 14 + { author_id: 5, paper_id: 14 }, + { author_id: 14, paper_id: 14 }, + + // paper 15 + { author_id: 6, paper_id: 15 }, + { author_id: 15, paper_id: 15 }, + + // paper 16 + { author_id: 1, paper_id: 16 }, + { author_id: 7, paper_id: 16 }, + + // paper 17 + { author_id: 2, paper_id: 17 }, + { author_id: 8, paper_id: 17 }, + + // paper 18 + { author_id: 3, paper_id: 18 }, + { author_id: 9, paper_id: 18 }, + + // paper 19 + { author_id: 4, paper_id: 19 }, + { author_id: 10, paper_id: 19 }, + + // paper 20 + { author_id: 5, paper_id: 20 }, + { author_id: 11, paper_id: 20 }, +]; diff --git a/Week2/assignment-w2/database.js b/Week2/assignment-w2/database.js new file mode 100644 index 000000000..f2eddb1a4 --- /dev/null +++ b/Week2/assignment-w2/database.js @@ -0,0 +1,34 @@ +import { Client } from "pg"; +//step1 : connect to postgres +const client = new Client({ + host: "localhost", + user: "hyfuser", + password: "hyfpassword", + database: "postgres", + port: 5432, +}); + +export const dbName = "prep-ex2"; + +try { + //Connect to postgres + await client.connect(); + + //check if the database already exists + const result = await client.query( + "SELECT 1 FROM pg_database WHERE datname =$1", + [dbName] + ); + + //no database + if (result.rowCount === 0) { + //Create database + await client.query(`CREATE DATABASE "${dbName}"`); + console.log("Database created"); + } +} catch (error) { + console.log("Database error ", error); +} finally { + //disconnects from the database and releases all resources. + await client.end(); //closes connection +} diff --git a/Week2/assignment-w2/package-lock.json b/Week2/assignment-w2/package-lock.json new file mode 100644 index 000000000..c2a449528 --- /dev/null +++ b/Week2/assignment-w2/package-lock.json @@ -0,0 +1,162 @@ +{ + "name": "assignment-w2", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "assignment-w2", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "pg": "^8.16.3" + } + }, + "node_modules/pg": { + "version": "8.16.3", + "resolved": "https://registry.npmjs.org/pg/-/pg-8.16.3.tgz", + "integrity": "sha512-enxc1h0jA/aq5oSDMvqyW3q89ra6XIIDZgCX9vkMrnz5DFTw/Ny3Li2lFQ+pt3L6MCgm/5o2o8HW9hiJji+xvw==", + "license": "MIT", + "dependencies": { + "pg-connection-string": "^2.9.1", + "pg-pool": "^3.10.1", + "pg-protocol": "^1.10.3", + "pg-types": "2.2.0", + "pgpass": "1.0.5" + }, + "engines": { + "node": ">= 16.0.0" + }, + "optionalDependencies": { + "pg-cloudflare": "^1.2.7" + }, + "peerDependencies": { + "pg-native": ">=3.0.1" + }, + "peerDependenciesMeta": { + "pg-native": { + "optional": true + } + } + }, + "node_modules/pg-cloudflare": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/pg-cloudflare/-/pg-cloudflare-1.2.7.tgz", + "integrity": "sha512-YgCtzMH0ptvZJslLM1ffsY4EuGaU0cx4XSdXLRFae8bPP4dS5xL1tNB3k2o/N64cHJpwU7dxKli/nZ2lUa5fLg==", + "license": "MIT", + "optional": true + }, + "node_modules/pg-connection-string": { + "version": "2.9.1", + "resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.9.1.tgz", + "integrity": "sha512-nkc6NpDcvPVpZXxrreI/FOtX3XemeLl8E0qFr6F2Lrm/I8WOnaWNhIPK2Z7OHpw7gh5XJThi6j6ppgNoaT1w4w==", + "license": "MIT" + }, + "node_modules/pg-int8": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/pg-int8/-/pg-int8-1.0.1.tgz", + "integrity": "sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==", + "license": "ISC", + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/pg-pool": { + "version": "3.10.1", + "resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.10.1.tgz", + "integrity": "sha512-Tu8jMlcX+9d8+QVzKIvM/uJtp07PKr82IUOYEphaWcoBhIYkoHpLXN3qO59nAI11ripznDsEzEv8nUxBVWajGg==", + "license": "MIT", + "peerDependencies": { + "pg": ">=8.0" + } + }, + "node_modules/pg-protocol": { + "version": "1.10.3", + "resolved": "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.10.3.tgz", + "integrity": "sha512-6DIBgBQaTKDJyxnXaLiLR8wBpQQcGWuAESkRBX/t6OwA8YsqP+iVSiond2EDy6Y/dsGk8rh/jtax3js5NeV7JQ==", + "license": "MIT" + }, + "node_modules/pg-types": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/pg-types/-/pg-types-2.2.0.tgz", + "integrity": "sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA==", + "license": "MIT", + "dependencies": { + "pg-int8": "1.0.1", + "postgres-array": "~2.0.0", + "postgres-bytea": "~1.0.0", + "postgres-date": "~1.0.4", + "postgres-interval": "^1.1.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/pgpass": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/pgpass/-/pgpass-1.0.5.tgz", + "integrity": "sha512-FdW9r/jQZhSeohs1Z3sI1yxFQNFvMcnmfuj4WBMUTxOrAyLMaTcE1aAMBiTlbMNaXvBCQuVi0R7hd8udDSP7ug==", + "license": "MIT", + "dependencies": { + "split2": "^4.1.0" + } + }, + "node_modules/postgres-array": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-2.0.0.tgz", + "integrity": "sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA==", + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/postgres-bytea": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/postgres-bytea/-/postgres-bytea-1.0.0.tgz", + "integrity": "sha512-xy3pmLuQqRBZBXDULy7KbaitYqLcmxigw14Q5sj8QBVLqEwXfeybIKVWiqAXTlcvdvb0+xkOtDbfQMOf4lST1w==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/postgres-date": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/postgres-date/-/postgres-date-1.0.7.tgz", + "integrity": "sha512-suDmjLVQg78nMK2UZ454hAG+OAW+HQPZ6n++TNDUX+L0+uUlLywnoxJKDou51Zm+zTCjrCl0Nq6J9C5hP9vK/Q==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/postgres-interval": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/postgres-interval/-/postgres-interval-1.2.0.tgz", + "integrity": "sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ==", + "license": "MIT", + "dependencies": { + "xtend": "^4.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/split2": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/split2/-/split2-4.2.0.tgz", + "integrity": "sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==", + "license": "ISC", + "engines": { + "node": ">= 10.x" + } + }, + "node_modules/xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", + "license": "MIT", + "engines": { + "node": ">=0.4" + } + } + } +} diff --git a/Week2/assignment-w2/package.json b/Week2/assignment-w2/package.json new file mode 100644 index 000000000..d640bcc58 --- /dev/null +++ b/Week2/assignment-w2/package.json @@ -0,0 +1,16 @@ +{ + "name": "assignment-w2", + "version": "1.0.0", + "main": "createTables.js", + "type": "module", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "description": "", + "dependencies": { + "pg": "^8.16.3" + } +} diff --git a/Week2/assignment-w2/selectQueries.js b/Week2/assignment-w2/selectQueries.js new file mode 100644 index 000000000..3e6607ffc --- /dev/null +++ b/Week2/assignment-w2/selectQueries.js @@ -0,0 +1,105 @@ +import { Client } from "pg"; +import { dbName } from "./database.js"; + +const config = { + host: "localhost", + port: 5432, + user: "hyfuser", + password: "hyfpassword", + database: dbName, +}; + +const client = new Client(config); + +const query1 = async () => { + console.log("The names of all 'authors' and their corresponding 'mentors':"); + + const result = await client.query( + "SELECT a.author_name AS authorName, b.author_name AS mentorName FROM authors a LEFT JOIN authors b ON a.mentor = b.author_id" + ); + + console.table(result.rows); +}; + +const query2 = async () => { + console.log("Authors and their published paper_title:"); + + const result = await client.query( + "SELECT a.*, rp.paper_title FROM authors a LEFT JOIN research_authors ra ON ra.author_id = a.author_id LEFT JOIN research_papers rp ON rp.paper_id = ra.paper_id AND rp.published = true" + ); + + console.table(result.rows); +}; + +const query3 = async () => { + console.log( + "All research papers and the number of authors that wrote that paper:" + ); + + const result = await client.query( + "SELECT rp.paper_title, COUNT(ra.author_id) AS authors_number FROM research_papers rp LEFT JOIN research_authors ra ON ra.paper_id = rp.paper_id GROUP BY rp.paper_title" + ); + + console.table(result.rows); +}; + +const query4 = async () => { + console.log("Sum of the research papers published by all female authors:"); + + const result = await client.query( + "SELECT COUNT(DISTINCT rp.paper_id) AS female_papers FROM research_papers rp INNER JOIN research_authors ra ON ra.paper_id = rp.paper_id INNER JOIN authors a ON a.author_id = ra.author_id WHERE a.gender = 'f'" + ); + + console.table(result.rows); +}; + +const query5 = async () => { + console.log("Average of the h-index of all authors per university:"); + + const result = await client.query( + "SELECT university, AVG(h_index) AS avg_h_index FROM authors GROUP BY university" + ); + + console.table(result.rows); +}; + +const query6 = async () => { + console.log("Sum of the research papers of the authors per university:"); + + const result = await client.query( + "SELECT a.university, COUNT(DISTINCT rp.paper_id) AS total_papers FROM research_papers rp LEFT JOIN research_authors ra ON ra.paper_id = rp.paper_id LEFT JOIN authors a ON a.author_id = ra.author_id GROUP BY a.university" + ); + + console.table(result.rows); +}; + +const query7 = async () => { + console.log( + "Minimum and maximum of the h-index of all authors per university:" + ); + + const result = await client.query( + "SELECT university, MIN(h_index) AS min_h_index, MAX(h_index) AS max_h_index FROM authors GROUP BY university" + ); + + console.table(result.rows); +}; + +async function selectAll() { + try { + await client.connect(); + console.log("Connected to PostgreSQL database!"); + + const queries = [query1, query2, query3, query4, query5, query6, query7]; + + for (const query of queries) { + await query(); + } + } catch (error) { + console.error("Error executing query:", error); + } finally { + await client.end(); + } +} + +selectAll();