Skip to content

Commit

Permalink
complete till step 19
Browse files Browse the repository at this point in the history
  • Loading branch information
sourav-sm committed Apr 16, 2024
1 parent e3deba0 commit 49777ba
Show file tree
Hide file tree
Showing 23 changed files with 1,612 additions and 2,062 deletions.
30 changes: 30 additions & 0 deletions src/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const readline = require('readline');
const {executeSELECTQuery,executeDELETEQuery,executeINSERTQuery} = require('./index');

const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});

rl.setPrompt('SQL> ');
console.log('SQL Query Engine CLI. Enter your SQL commands, or type "exit" to quit.');

rl.prompt();

rl.on('line', async (line) => {
if (line.toLowerCase() === 'exit') {
rl.close();
return;
}

try {
// Execute the query - do your own implementation
}catch (error) {
console.error('Error:', error.message);
}

rl.prompt();
}).on('close', () => {
console.log('Exiting SQL CLI');
process.exit(0);
});
7 changes: 6 additions & 1 deletion src/csvReader.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const fs = require('fs');
const csv = require('csv-parser');
const { parse } = require('json2csv');

function readCSV(filePath) {
const results = [];
Expand All @@ -17,5 +18,9 @@ function readCSV(filePath) {
});
}

module.exports = readCSV;
async function writeCSV(filename, data) {
const csv = parse(data);
fs.writeFileSync(filename, csv);
}

module.exports = {readCSV,writeCSV};
Loading

0 comments on commit 49777ba

Please sign in to comment.