From 9148fa6e2fad9d54e3451a4478e03f55f0a9fa3c Mon Sep 17 00:00:00 2001 From: RossTheRoss Date: Sun, 16 May 2021 21:38:59 -0500 Subject: Rearrange files --- .../hw6/strap012_hw6/create_accounts_table.js | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 OLD/csci4131/hw6/strap012_hw6/create_accounts_table.js (limited to 'OLD/csci4131/hw6/strap012_hw6/create_accounts_table.js') diff --git a/OLD/csci4131/hw6/strap012_hw6/create_accounts_table.js b/OLD/csci4131/hw6/strap012_hw6/create_accounts_table.js new file mode 100644 index 0000000..61b2602 --- /dev/null +++ b/OLD/csci4131/hw6/strap012_hw6/create_accounts_table.js @@ -0,0 +1,41 @@ +/* +TO DO: +----- +READ ALL COMMENTS AND REPLACE VALUES ACCORDINGLY +*/ + +const mysql = require("mysql"); + +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 sql = `CREATE TABLE tbl_accounts ( + acc_id INT NOT NULL AUTO_INCREMENT, + acc_name VARCHAR(20), + acc_login VARCHAR(20), + acc_password VARCHAR(200), + PRIMARY KEY (acc_id) + )`; + + console.log("Attempting to create table: tbl_accounts"); + dbCon.query(sql, function (err, result) { + if (err) { + throw err; + } + console.log("Table tbl_accounts created"); + }); + + dbCon.end(); +}); -- cgit v1.2.3