aboutsummaryrefslogtreecommitdiffstats
path: root/csci4131/hw7/create_accounts_table.js
diff options
context:
space:
mode:
authorMatt Strapp <matt@mattstrapp.net>2022-05-24 11:18:46 -0500
committerMatt Strapp <matt@mattstrapp.net>2022-05-24 11:19:55 -0500
commit7a73162607544204032aa66cce755daf21edebda (patch)
tree58578e01f15f34a855d99c32898db9d7a1603e67 /csci4131/hw7/create_accounts_table.js
parentdo some stuff (diff)
downloadhomework-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 'csci4131/hw7/create_accounts_table.js')
-rw-r--r--csci4131/hw7/create_accounts_table.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/csci4131/hw7/create_accounts_table.js b/csci4131/hw7/create_accounts_table.js
new file mode 100644
index 0000000..61b2602
--- /dev/null
+++ b/csci4131/hw7/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();
+});