JavaScript: Add test demonstrating more SQL flow.

This commit is contained in:
Max Schaefer
2020-06-24 09:56:01 +01:00
parent 68b3ccdc65
commit 6d68036d85
3 changed files with 27 additions and 0 deletions

View File

@@ -4,6 +4,8 @@
| mssql3.js:12:13:12:22 | 'password' | password |
| mysql1.js:6:14:6:17 | 'me' | user name |
| mysql1.js:7:14:7:21 | 'secret' | password |
| mysql1a.js:10:9:10:12 | 'me' | user name |
| mysql1a.js:11:13:11:20 | 'secret' | password |
| mysql2.js:7:21:7:25 | 'bob' | user name |
| mysql2.js:8:21:8:28 | 'secret' | password |
| mysql2tst.js:8:9:8:14 | 'root' | user name |

View File

@@ -5,6 +5,7 @@
| mssql2.js:22:24:22:43 | 'select 1 as number' |
| mysql1.js:13:18:13:43 | 'SELECT ... lution' |
| mysql1.js:18:18:22:1 | {\\n s ... vid']\\n} |
| mysql1a.js:17:18:17:43 | 'SELECT ... lution' |
| mysql2.js:12:12:12:37 | 'SELECT ... lution' |
| mysql2tst.js:14:3:14:62 | 'SELECT ... ` > 45' |
| mysql2tst.js:23:3:23:56 | 'SELECT ... e` > ?' |

View File

@@ -0,0 +1,24 @@
// Adapted from the documentation of https://github.com/mysqljs/mysql,
// which is licensed under the MIT license; see file mysqljs-License.
function importMySql() {
return require("mysql");
}
var connection = importMySql().createConnection({
host: 'localhost',
user: 'me',
password: 'secret',
database: 'my_db'
});
connection.connect();
connection.query('SELECT 1 + 1 AS solution', function (error, results, fields) {
if (error) throw error;
console.log('The solution is: ', results[0].solution);
});
connection.end();
exports.connection = connection;