diff options
author | Matt Strapp <matt@mattstrapp.net> | 2022-05-24 11:18:46 -0500 |
---|---|---|
committer | Matt Strapp <matt@mattstrapp.net> | 2022-05-24 11:19:55 -0500 |
commit | 7a73162607544204032aa66cce755daf21edebda (patch) | |
tree | 58578e01f15f34a855d99c32898db9d7a1603e67 /OLD/csci4131/hw7/insert_into_accounts_table.js | |
parent | do some stuff (diff) | |
download | homework-7a73162607544204032aa66cce755daf21edebda.tar homework-7a73162607544204032aa66cce755daf21edebda.tar.gz homework-7a73162607544204032aa66cce755daf21edebda.tar.bz2 homework-7a73162607544204032aa66cce755daf21edebda.tar.lz homework-7a73162607544204032aa66cce755daf21edebda.tar.xz homework-7a73162607544204032aa66cce755daf21edebda.tar.zst homework-7a73162607544204032aa66cce755daf21edebda.zip |
Graduate
Signed-off-by: Matt Strapp <matt@mattstrapp.net>
Diffstat (limited to 'OLD/csci4131/hw7/insert_into_accounts_table.js')
-rw-r--r-- | OLD/csci4131/hw7/insert_into_accounts_table.js | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/OLD/csci4131/hw7/insert_into_accounts_table.js b/OLD/csci4131/hw7/insert_into_accounts_table.js deleted file mode 100644 index 0be14ce..0000000 --- a/OLD/csci4131/hw7/insert_into_accounts_table.js +++ /dev/null @@ -1,45 +0,0 @@ -/* -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 = 'admin%'; // replace with password chosen by you OR retain the same value - const passwordHash = bcrypt.hashSync(myPlaintextPassword, saltRounds); - - const rowToBeInserted = { - acc_name: 'admin$', // replace with acc_name chosen by you OR retain the same value - acc_login: 'admin$', // 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(); -}); |