From 89a64a8fef7e3cb296bc3d1c86320b59ee594c54 Mon Sep 17 00:00:00 2001 From: Sean Edmunds Date: Fri, 30 Dec 2022 12:25:46 -0600 Subject: [PATCH] New SQL def & added code example to read from SQL --- SQLDefinitions/tables.sql | 13 ++++++++++--- api/server.js | 10 ++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/SQLDefinitions/tables.sql b/SQLDefinitions/tables.sql index 20794c77..4ee27938 100644 --- a/SQLDefinitions/tables.sql +++ b/SQLDefinitions/tables.sql @@ -1,4 +1,4 @@ -CREATE TABLE `apps` ( +CREATE TABLE `apps` ( `id` TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT, `name` VARCHAR(30), `url` VARCHAR(50), @@ -11,8 +11,15 @@ CREATE TABLE `apps` ( CREATE TABLE `links` ( `id` TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT, `category` VARCHAR(20), - `name` VARCHAR(20), - `url` VARCHAR(50), + `name` VARCHAR(50), + `url` VARCHAR(100), + PRIMARY KEY (`id`) +); + +CREATE TABLE `tabs` ( + `id` TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT, + `name` VARCHAR(50), + `NSFW` BOOLEAN, PRIMARY KEY (`id`) ); diff --git a/api/server.js b/api/server.js index 4d9d5c12..bce23aac 100644 --- a/api/server.js +++ b/api/server.js @@ -33,6 +33,16 @@ try { var links = require('../src/links.json'); } +// WIP learning to read from DB +con.connect(function(err) { + if (err) throw err; + console.log("Connected!"); + con.query(sql, function (err, result) { + if (err) throw err; + console.log("Result: " + result); + }); + }); + //Read personal data try { var personaldata = require('../src/personaldata.json');