aboutsummaryrefslogtreecommitdiffstats
path: root/csci4131/hw6/strap012_hw6/create_contacts_table.js
diff options
context:
space:
mode:
authorRossTheRoss <mstrapp@protonmail.com>2021-04-13 14:22:16 -0500
committerRossTheRoss <mstrapp@protonmail.com>2021-04-13 14:22:16 -0500
commit20dba29f9c01e6ff4142fc8dd73d7e7c33a42034 (patch)
tree2081f57a595a438a40904210139c495defd994ff /csci4131/hw6/strap012_hw6/create_contacts_table.js
parentoops (diff)
downloadhomework-20dba29f9c01e6ff4142fc8dd73d7e7c33a42034.tar
homework-20dba29f9c01e6ff4142fc8dd73d7e7c33a42034.tar.gz
homework-20dba29f9c01e6ff4142fc8dd73d7e7c33a42034.tar.bz2
homework-20dba29f9c01e6ff4142fc8dd73d7e7c33a42034.tar.lz
homework-20dba29f9c01e6ff4142fc8dd73d7e7c33a42034.tar.xz
homework-20dba29f9c01e6ff4142fc8dd73d7e7c33a42034.tar.zst
homework-20dba29f9c01e6ff4142fc8dd73d7e7c33a42034.zip
start hw6
Diffstat (limited to 'csci4131/hw6/strap012_hw6/create_contacts_table.js')
-rw-r--r--csci4131/hw6/strap012_hw6/create_contacts_table.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/csci4131/hw6/strap012_hw6/create_contacts_table.js b/csci4131/hw6/strap012_hw6/create_contacts_table.js
new file mode 100644
index 0000000..bcad389
--- /dev/null
+++ b/csci4131/hw6/strap012_hw6/create_contacts_table.js
@@ -0,0 +1,44 @@
+/*
+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_contacts (
+ contact_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ name VARCHAR(30),
+ category VARCHAR(40),
+ location VARCHAR(300),
+ contact_info VARCHAR(200),
+ email VARCHAR(30),
+ website VARCHAR(300),
+ website_url VARCHAR(300)
+ )`;
+
+ console.log("Attempting to create table: tbl_contacts");
+ dbCon.query(sql, function (err, result) {
+ if (err) {
+ throw err;
+ }
+ console.log("Table tbl_accounts created");
+ });
+
+ dbCon.end();
+});