Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import * as readline from 'readline';
- import * as mysql from 'mysql';
- let rl = readline.createInterface({
- input: process.stdin,
- output: process.stdout
- });
- const connection = mysql.createConnection({
- host: 'localhost',
- user: 'root',
- password: '',
- database: 'scriptioner'
- });
- connection.connect((err: string) => {
- if (err) throw err;
- console.log('Connected!');
- });
- connection.query('SELECT * FROM questions ORDER BY RAND() LIMIT 5', (err, rowsFetched) => {
- if (err) throw err;
- for(let row of rowsFetched){
- rl.question(row.question, (answer) => {
- console.log(row.question);
- });
- }
- });
- /**
- connection.query('SELECT * FROM questions ORDER BY RAND() LIMIT 1', (err, rows) => {
- if (err) throw err;
- console.log(rows);
- });
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement