aboutsummaryrefslogtreecommitdiffstats
path: root/OLD/csci4131/hw6/strap012_hw6/insert_into_accounts_table.js
diff options
context:
space:
mode:
authorRossTheRoss <mstrapp@protonmail.com>2021-05-16 21:38:59 -0500
committerRossTheRoss <mstrapp@protonmail.com>2021-05-16 21:38:59 -0500
commit9148fa6e2fad9d54e3451a4478e03f55f0a9fa3c (patch)
tree9e739b11361f5fd122b31cfce107947502b69809 /OLD/csci4131/hw6/strap012_hw6/insert_into_accounts_table.js
parentAdd trash (diff)
downloadhomework-9148fa6e2fad9d54e3451a4478e03f55f0a9fa3c.tar
homework-9148fa6e2fad9d54e3451a4478e03f55f0a9fa3c.tar.gz
homework-9148fa6e2fad9d54e3451a4478e03f55f0a9fa3c.tar.bz2
homework-9148fa6e2fad9d54e3451a4478e03f55f0a9fa3c.tar.lz
homework-9148fa6e2fad9d54e3451a4478e03f55f0a9fa3c.tar.xz
homework-9148fa6e2fad9d54e3451a4478e03f55f0a9fa3c.tar.zst
homework-9148fa6e2fad9d54e3451a4478e03f55f0a9fa3c.zip
Rearrange files
Diffstat (limited to 'OLD/csci4131/hw6/strap012_hw6/insert_into_accounts_table.js')
-rw-r--r--OLD/csci4131/hw6/strap012_hw6/insert_into_accounts_table.js45
1 files changed, 45 insertions, 0 deletions
diff --git a/OLD/csci4131/hw6/strap012_hw6/insert_into_accounts_table.js b/OLD/csci4131/hw6/strap012_hw6/insert_into_accounts_table.js
new file mode 100644
index 0000000..3157ce3
--- /dev/null
+++ b/OLD/csci4131/hw6/strap012_hw6/insert_into_accounts_table.js
@@ -0,0 +1,45 @@
+/*
+TO DO:
+-----
+READ ALL COMMENTS AND REPLACE VALUES ACCORDINGLY
+*/
+
+const mysql = require("mysql");
+const bcrypt = require('bcrypt');
+
+const dbCon = mysql.createConnection({
+ host: "cse-mysql-classes-01.cse.umn.edu",
+ user: "C4131S21U83", // replace with the database user provided to you
+ password: "6919", // replace with the database password provided to you
+ database: "C4131S21U83", // replace with the database user provided to you
+ port: 3306
+});
+
+console.log("Attempting database connection");
+dbCon.connect(function (err) {
+ if (err) {
+ throw err;
+ }
+
+ console.log("Connected to database!");
+
+ const saltRounds = 10;
+ const myPlaintextPassword = 'tango'; // replace with password chosen by you OR retain the same value
+ const passwordHash = bcrypt.hashSync(myPlaintextPassword, saltRounds);
+
+ const rowToBeInserted = {
+ acc_name: 'charlie', // replace with acc_name chosen by you OR retain the same value
+ acc_login: 'charlie', // replace with acc_login chosen by you OR retain the same value
+ acc_password: passwordHash
+ };
+
+ console.log("Attempting to insert record into tbl_accounts");
+ dbCon.query('INSERT tbl_accounts SET ?', rowToBeInserted, function (err, result) {
+ if (err) {
+ throw err;
+ }
+ console.log("Table record inserted!");
+ });
+
+ dbCon.end();
+});