Skip to content

Commit 89e5434

Browse files
author
Aya Moosa
authored
Merge pull request #86 from oslabs-beta/master
OS labs Beta to OSLabs main
2 parents 900e8a6 + ff78b42 commit 89e5434

20 files changed

+542
-1133
lines changed

Diff for: .vscode/launch.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "chrome",
9+
"request": "launch",
10+
"name": "Launch Chrome against localhost",
11+
"url": "http://localhost:8080",
12+
"webRoot": "${workspaceFolder}"
13+
}
14+
]
15+
}

Diff for: README.md

+9-6
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
<img src="./assets/readmeImages/logo_readme.png" height=300/>
44

55
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/oslabs-beta/SeeQR)
6-
![Release: 8.0.1](https://img.shields.io/badge/Release-8.0.1-red)
6+
![Release: 9.0.1](https://img.shields.io/badge/Release-9.0.1-red)
77
![License: MIT](https://img.shields.io/badge/License-MIT-orange.svg)
88
![Contributions Welcome](https://img.shields.io/badge/Contributions-welcome-blue.svg)
99
[![Twitter](https://img.shields.io/twitter/url?style=social&url=https%3A%2F%2Ftwitter.com%2Ftheseeqr)](https://twitter.com/theseeqr)
1010
[![Github stars](https://img.shields.io/github/stars/open-source-labs/SeeQR?style=social)](https://github.com/open-source-labs/SeeQR)
1111

12-
[SeeQR.info](http://www.seeqr.info)
12+
[SeeQRapp.com](http://www.seeqrapp.com)
1313

1414
<p>SeeQR is a <b>convenient one-stop shop</b> for efficient SQL database manipulation and performance testing. SeeQR can be used throughout the database life-cycle, from creation to testing.</p>
1515

@@ -27,11 +27,13 @@
2727

2828
## Getting Started
2929

30-
To get started on contributing to this project:
30+
To get started on contributing and editing databases to this project:
31+
3132

3233
1. Download and install [Postgres](https://www.postgresql.org/download/) to access SeeQR's Postgres features and/or [MySQL](https://dev.mysql.com/downloads/mysql/) to access it's MySQL features.
3334
2. Ensure that psql and/or mysql are available in the `$PATH`.
34-
3. Download the latest version of [SeeQR](https://github.com/open-source-labs/seeqr/releases/latest).
35+
3. Create users with passwords and permissions for both [PostgreSQL](https://phoenixnap.com/kb/postgres-create-user) and [MySQL](https://www.digitalocean.com/community/tutorials/how-to-create-a-new-user-and-grant-permissions-in-mysql). Linked are instructions for Mac (Homebrew) and Linux/WSL.
36+
4. Download the latest version of [SeeQR](https://github.com/open-source-labs/seeqr/releases/latest).
3537

3638
## Built With
3739

@@ -81,7 +83,7 @@ To get started on contributing to this project:
8183
<div align="center">
8284
<img src="./assets/readmeImages/gifs/dummy_data.gif" width=800/>
8385
</div>
84-
- Create/Edit Database <i>(currently in beta)</i>
86+
- Create/Edit Database
8587

8688
- Users can create a new database from scratch by clicking the `Create New Database` button at the bottom of the sidebar.
8789
- Users can modify the newly created database as well as any existing databases using the `ER Diagram` to create/change/delete tables and columns.
@@ -93,6 +95,7 @@ To get started on contributing to this project:
9395
<img src="./assets/readmeImages/gifs/create_db3.gif" width=800/>
9496
<img src="./assets/readmeImages/gifs/modify_db.gif" width=800/>
9597
</div>
98+
9699
- Queries
97100

98101
- In the 'QUERIES' view, the main panel is where the query input text field is located, utilizing CodeMirror. The paint button in the top right corner of the panel auto-formats the inputted query.
@@ -162,7 +165,7 @@ We've released SeeQR because it's a useful tool to help optimize SQL databases.
162165

163166
## Core Team
164167

165-
[Fred Jeong](https://github.com/fred-jeong) | [Gabriel Kime](https://github.com/wizardbusiness) | [Chris Fryer](github.com/frynoceros) | [Ian Grepo](https://github.com/RadiantGH) | [Michelle Chang](https://github.com/mkchang168) | [Jake Bradbeer](https://github.com/JBradbeer) | [Bryan Santos](https://github.com/santosb93) | [William Trey Lewis](https://github.com/treyfrog128) | [Brandon Lee](https://github.com/BrandonW-Lee) | [Casey Escovedo](https://github.com/caseyescovedo) | [Casey Walker](https://github.com/cwalker3011) | [Catherine Chiu](https://github.com/catherinechiu) | [Chris Akinrinade](https://github.com/chrisakinrinade) | [Cindy Chau](https://github.com/cindychau) | [Claudio Santos](https://github.com/Claudiohbsantos) | [Eric Han](https://github.com/ericJH92) | [Faraz Akhtar](https://github.com/faraza22) | [Frank Norton](https://github.com/FrankNorton32) | [Harrison Nam](https://github.com/harrynam07) | [James Kolotouros](https://github.com/dkolotouros) | [Jennifer Courtner](https://github.com/jcourtner) | [John Wagner](https://github.com/jwagner988) | [Justin Dury-Agri](https://github.com/justinD-A) | [Justin Hicks](https://github.com/JuiceBawks) | [Katie Klochan](https://github.com/kklochan) | [May Wirapa Boonyasurat](https://github.com/mimiwrp) | [Mercer Stronck](https://github.com/mercerstronck) | [Muhammad Trad](https://github.com/muhammadtrad) | [Richard Guo](https://github.com/richardguoo) | [Richard Lam](https://github.com/rlam108) | [Sam Frakes](https://github.com/frakes413) | [Serena Kuo](https://github.com/serenackuo) | [Timothy Sin](https://github.com/timothysin) | [Vincent Trang](https://github.com/vincentt114)
168+
[Aya Moosa](https://github.com/Hiya-its-Aya) | [Trevor Ferguson](https://github.com/TrevorJFerguson) | [Pauline Nguyen](https://github.com/paulinekpn) | [Utkarsh Uppal](https://github.com/utyvert) | [Fred Jeong](https://github.com/fred-jeong) | [Gabriel Kime](https://github.com/wizardbusiness) | [Chris Fryer](github.com/frynoceros) | [Ian Grepo](https://github.com/RadiantGH) | [Michelle Chang](https://github.com/mkchang168) | [Jake Bradbeer](https://github.com/JBradbeer) | [Bryan Santos](https://github.com/santosb93) | [William Trey Lewis](https://github.com/treyfrog128) | [Brandon Lee](https://github.com/BrandonW-Lee) | [Casey Escovedo](https://github.com/caseyescovedo) | [Casey Walker](https://github.com/cwalker3011) | [Catherine Chiu](https://github.com/catherinechiu) | [Chris Akinrinade](https://github.com/chrisakinrinade) | [Cindy Chau](https://github.com/cindychau) | [Claudio Santos](https://github.com/Claudiohbsantos) | [Eric Han](https://github.com/ericJH92) | [Faraz Akhtar](https://github.com/faraza22) | [Frank Norton](https://github.com/FrankNorton32) | [Harrison Nam](https://github.com/harrynam07) | [James Kolotouros](https://github.com/dkolotouros) | [Jennifer Courtner](https://github.com/jcourtner) | [John Wagner](https://github.com/jwagner988) | [Justin Dury-Agri](https://github.com/justinD-A) | [Justin Hicks](https://github.com/JuiceBawks) | [Katie Klochan](https://github.com/kklochan) | [May Wirapa Boonyasurat](https://github.com/mimiwrp) | [Mercer Stronck](https://github.com/mercerstronck) | [Muhammad Trad](https://github.com/muhammadtrad) | [Richard Guo](https://github.com/richardguoo) | [Richard Lam](https://github.com/rlam108) | [Sam Frakes](https://github.com/frakes413) | [Serena Kuo](https://github.com/serenackuo) | [Timothy Sin](https://github.com/timothysin) | [Vincent Trang](https://github.com/vincentt114)
166169

167170

168171
## License

Diff for: __tests__/frontend/lib/queries.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
window.require = ((str: string) => str) as any
22
import * as queries from '../../../frontend/lib/queries';
3-
import type { QueryData, ExplainJson } from '../../../frontend/types';
3+
import type { QueryData } from '../../../frontend/types';
44

55
const first: Partial<QueryData> = {
66
label: 'firstQuery',

Diff for: backend/DummyD/dummyDataMain.ts

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ const getRandomInt = (min: number, max: number) => {
2929
const generateDataByType = (columnObj: ColumnObj): string | number => {
3030
let length;
3131
// faker.js method to generate data by type
32+
console.log('columnObj_datatype: ', columnObj.data_type)
33+
3234
switch (columnObj.data_type) {
3335
case 'smallint':
3436
return faker.random.number({ min: -32768, max: 32767 });

Diff for: backend/channels.ts

+23-16
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ ipcMain.on('return-db-list', (event, dbType: DBType = DBType.Postgres) => {
7474

7575
db.setBaseConnections()
7676
.then(() => {
77-
db.getLists()
77+
db.getLists('', dbType)
7878
.then((data: DBList) => {
7979
event.sender.send('db-lists', data);
8080
logger("Sent 'db-lists' from 'return-db-list'", LogType.SEND);
@@ -156,7 +156,7 @@ ipcMain.handle(
156156
await db.query(dropDBScript, null, dbType);
157157

158158
// send updated db info
159-
const dbsAndTables: DBList = await db.getLists();
159+
const dbsAndTables: DBList = await db.getLists(dbName, dbType);
160160
event.sender.send('db-lists', dbsAndTables);
161161
logger("Sent 'db-lists' from 'drop-db'", LogType.SEND);
162162
} finally {
@@ -228,7 +228,7 @@ ipcMain.handle(
228228
}
229229

230230
// update frontend with new db list
231-
const dbsAndTableInfo: DBList = await db.getLists();
231+
const dbsAndTableInfo: DBList = await db.getLists('', dbType);
232232
event.sender.send('db-lists', dbsAndTableInfo);
233233
logger("Sent 'db-lists' from 'duplicate-db'", LogType.SEND);
234234
} finally {
@@ -288,7 +288,7 @@ ipcMain.handle(
288288
}
289289

290290
// update frontend with new db list
291-
const dbsAndTableInfo: DBList = await db.getLists();
291+
const dbsAndTableInfo: DBList = await db.getLists('', dbType);
292292
event.sender.send('db-lists', dbsAndTableInfo);
293293
logger("Sent 'db-lists' from 'import-db'", LogType.SEND);
294294
} finally {
@@ -343,7 +343,7 @@ ipcMain.handle(
343343
dbType
344344
);
345345
explainResults = results[0][0];
346-
console.log('mysql explain results', explainResults);
346+
// console.log('mysql explain results', explainResults);
347347

348348
console.log(LogType.WARNING, results);
349349
}
@@ -361,9 +361,9 @@ ipcMain.handle(
361361
console.log('returnedRows in channels for MySQL', returnedRows);
362362
}
363363
if (dbType === DBType.Postgres) {
364-
console.log('results in channels for Postgres', results);
364+
// console.log('results in channels for Postgres', results);
365365
returnedRows = results.rows;
366-
console.log('returnedRows in channels for Postgres', returnedRows);
366+
// console.log('returnedRows in channels for Postgres', returnedRows);
367367
}
368368
} catch (e: any) {
369369
error = e.toString();
@@ -383,7 +383,7 @@ ipcMain.handle(
383383

384384
// send updated db info in case query affected table or database information
385385
// must be run after we connect back to the originally selected so tables information is accurate
386-
const dbsAndTables: DBList = await db.getLists();
386+
const dbsAndTables: DBList = await db.getLists('', dbType);
387387
event.sender.send('db-lists', dbsAndTables);
388388
logger(
389389
"Sent 'db-lists' from 'run-query'",
@@ -440,26 +440,30 @@ interface dummyDataRequestPayload {
440440
rows: number;
441441
}
442442

443-
ipcMain.handle(
443+
ipcMain.handle( // generate dummy data
444444
'generate-dummy-data',
445445
async (event, data: dummyDataRequestPayload, dbType: DBType) => {
446446
logger("Received 'generate-dummy-data'", LogType.RECEIVE);
447447
// send notice to front end that DD generation has been started
448448
event.sender.send('async-started');
449-
449+
console.log('genereatedata ipcMain dbType: ', dbType)
450450
let feedback: Feedback = {
451451
type: '',
452452
message: '',
453453
};
454454
try {
455+
console.log('data in generate-dummy-data', data); // gets here fine
456+
455457
// Retrieves the Primary Keys and Foreign Keys for all the tables
456-
const tableInfo: ColumnObj[] = await db.getTableInfo(data.tableName);
457-
458+
const tableInfo: ColumnObj[] = await db.getTableInfo(data.tableName, dbType); // passed in dbType to second argument
459+
console.log('tableInfo in generate-dummy-data', tableInfo); // working
460+
458461
// generate dummy data
459462
const dummyArray: DummyRecords = await generateDummyData(
460463
tableInfo,
461464
data.rows
462465
);
466+
console.log('dummyArray output: ', dummyArray)
463467
// generate insert query string to insert dummy records
464468
const columnsStringified = '('
465469
.concat(dummyArray[0].join(', '))
@@ -491,9 +495,11 @@ ipcMain.handle(
491495
message: err,
492496
};
493497
} finally {
498+
console.log('dbType inside generate-dummy-data', dbType)
494499
// send updated db info in case query affected table or database information
495-
const dbsAndTables: DBList = await db.getLists();
496-
event.sender.send('db-lists', dbsAndTables);
500+
const dbsAndTables: DBList = await db.getLists('', dbType); // dummy data clear error is from here
501+
console.log('dbsAndTables in generate-dummy-data', dbsAndTables)
502+
event.sender.send('db-lists', dbsAndTables); // dummy data clear error is from here
497503

498504
// send feedback back to FE
499505
event.sender.send('feedback', feedback);
@@ -534,7 +540,7 @@ ipcMain.handle(
534540
await db.connectToDB(newDbName, dbType);
535541

536542
// update DBList in the sidebar to show this new db
537-
const dbsAndTableInfo: DBList = await db.getLists();
543+
const dbsAndTableInfo: DBList = await db.getLists(newDbName, dbType);
538544
event.sender.send('db-lists', dbsAndTableInfo);
539545
logger("Sent 'db-lists' from 'initialize-db'", LogType.SEND);
540546
} catch (e) {
@@ -578,7 +584,7 @@ ipcMain.handle(
578584
} finally {
579585
// send updated db info in case query affected table or database information
580586
// must be run after we connect back to the originally selected so tables information is accurate
581-
const dbsAndTables: DBList = await db.getLists();
587+
const dbsAndTables: DBList = await db.getLists('', dbType);
582588
event.sender.send('db-lists', dbsAndTables);
583589
logger("Sent 'db-lists' from 'update-db'", LogType.SEND);
584590

@@ -625,6 +631,7 @@ ipcMain.handle(
625631
};
626632
} finally {
627633
// send updated db info
634+
628635
const updatedDb: DBList = await db.getLists(dbName, dbType);
629636
event.sender.send('db-lists', updatedDb);
630637

Diff for: backend/helperFunctions.ts

+19-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/* eslint-disable object-shorthand */
22
import { DBType } from './BE_types';
33
const { exec } = require('child_process'); // Child_Process: Importing Node.js' child_process API
4-
const { dialog } = require('electron'); // Dialog: display native system dialogs for opening and saving files, alerting, etc
4+
const { dialog } = require('electron'); // Dialog: display native system dialogs for opening and saving files, alerting, etcim
5+
const docConfig = require('./_documentsConfig')
56
// ************************************** CLI COMMANDS & SQL Queries TO CREATE, DELETE, COPY DB SCHEMA, etc. ************************************** //
67

78
// Generate SQL queries & CLI commands to be executed in pg and child process respectively
@@ -63,9 +64,11 @@ const helperFunctions: HelperFunctions = {
6364

6465
// import SQL file into new DB created
6566
runSQLFunc: function (dbName, file, dbType: DBType) {
66-
const PG = `psql -U postgres -d "${dbName}" -f "${file}"`;
67+
const SQL_data = docConfig.getFullConfig();
68+
console.log(SQL_data)
69+
const PG = `PGPASSWORD=${SQL_data.pg_pass} psql -U ${SQL_data.pg_user} -d "${dbName}" -f "${file}" -p ${SQL_data.pg_port}`;
6770
// const MYSQL = `mysql -u root -p ${dbName} < ${file}`;
68-
const MYSQL = `mysql -uroot -p; use ${dbName}; source ${file}`;
71+
const MYSQL = `export MYSQL_PWD='${SQL_data.mysql_pass}'; mysql -u${SQL_data.mysql_user} --port=${SQL_data.mysql_port} ${dbName} < ${file}`;
6972

7073
console.log(`runSQLFunc MySQL: ${MYSQL}, ${dbType}`);
7174
console.log(`runSQLFunc PG: ${PG}, ${dbType}`);
@@ -75,8 +78,9 @@ const helperFunctions: HelperFunctions = {
7578

7679
// import TAR file into new DB created
7780
runTARFunc: function (dbName, file, dbType: DBType) {
78-
const PG = `pg_restore -U postgres -d "${dbName}" "${file}"`;
79-
const MYSQL = `mysqldump -u root -p ${dbName} > ${file}`;
81+
const SQL_data = docConfig.getFullConfig();
82+
const PG = `PGPASSWORD=${SQL_data.pg_pass} pg_restore -U ${SQL_data.pg_user} -p ${SQL_data.pg_port} -d "${dbName}" "${file}" `;
83+
const MYSQL = `export MYSQL_PWD='${SQL_data.mysql_pass}'; mysqldump -u ${SQL_data.mysql_user} --port=${SQL_data.mysql_port} ${dbName} > ${file}`;
8084

8185
console.log(`runTARFunc MySQL: ${MYSQL}, ${dbType}`);
8286
console.log(`runTARFunc PG: ${PG}, ${dbType}`);
@@ -86,8 +90,9 @@ const helperFunctions: HelperFunctions = {
8690

8791
// make a full copy of the schema
8892
runFullCopyFunc: function (dbCopyName, newFile, dbType: DBType) {
89-
const PG = `pg_dump -U postgres -F p -d "${dbCopyName}" > "${newFile}"`;
90-
const MYSQL = `mysqldump -h localhost -u root -p --no-data ${dbCopyName} > ${newFile}`;
93+
const SQL_data = docConfig.getFullConfig();
94+
const PG = `PGPASSWORD=${SQL_data.pg_pass} pg_dump -s -U ${SQL_data.pg_user} -p ${SQL_data.pg_port} -Fp -d ${dbCopyName} > "${newFile}"`;
95+
const MYSQL = `export MYSQL_PWD='${SQL_data.mysql_pass}'; mysqldump -h localhost -u ${SQL_data.mysql_user} ${dbCopyName} > ${newFile}`;
9196

9297
console.log(`runFullCopyFunc MySQL: ${MYSQL}, ${dbType}`);
9398
console.log(`runFullCopyFunc PG: ${PG}, ${dbType}`);
@@ -97,20 +102,22 @@ const helperFunctions: HelperFunctions = {
97102

98103
// make a hollow copy of the schema
99104
runHollowCopyFunc: function (dbCopyName, file, dbType: DBType) {
100-
const PG = `pg_dump -s -U postgres -F p -d "${dbCopyName}" > "${file}"`;
101-
const MYSQL = `mysqldump -h localhost -u root -p --no-data ${dbCopyName} > ${file}`;
105+
const SQL_data = docConfig.getFullConfig();
106+
const PG = ` PGPASSWORD=${SQL_data.pg_pass} pg_dump -s -U ${SQL_data.pg_user} -p ${SQL_data.pg_port} -F p -d "${dbCopyName}" > "${file}"`;
107+
const MYSQL = `export MYSQL_PWD='${SQL_data.mysql_pass}'; mysqldump -h localhost -u ${SQL_data.mysql_user} --port=${SQL_data.mysql_port} ${dbCopyName} > ${file}`;
102108

103109
console.log(`runHollowCopyFunc MySQL: ${MYSQL}, ${dbType}`);
104110
console.log(`runHollowCopyFunc PG: ${PG}, ${dbType}`);
105-
106111
return dbType === DBType.Postgres ? PG : MYSQL;
107112
},
108113

109114
// promisified execute to execute commands in the child process
110115
promExecute: (cmd: string) =>
111116
new Promise((resolve, reject) => {
112-
exec(cmd, (error, stdout, stderr) => {
113-
if (error) return reject(error);
117+
exec(cmd, {timeout: 5000}, (error, stdout, stderr) => {
118+
if (error){
119+
console.log(error)
120+
return reject(error)};
114121
if (stderr) return reject(new Error(stderr));
115122
return resolve({ stdout, stderr });
116123
});

Diff for: backend/main.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// eslint-disable-next-line import/no-extraneous-dependencies
2-
import { FamilyRestroomRounded } from '@mui/icons-material';
32
import { BrowserWindow, Menu } from 'electron';
43

54
const { app } = require('electron');

0 commit comments

Comments
 (0)