Curriculum: Is it easy for us to substitute PostgreSQL for MySQL in this dev.to tutorial?

Created on 20 Feb 2019  路  5Comments  路  Source: Techtonica/curriculum

The roadmap for tomorrow, Thurs Feb 21, contains a line item Practice building an API with ExpressJS/SQL with the lesson as: https://dev.to/achowba/build-a-simple-app-using-node-js-and-mysql-19me

However, today we're having everyone install and play around with PostgreSQL, not MySQL. Rather than have everyone also install MySQL tomorrow, I'd like to have everyone use PostgreSQL. I haven't done the dev.to tutorial myself and don't know if that's easy to do. I'm hoping it's easy to substitute and we can just follow the tutorial, but use Postgres instead of MySQL when it says MySQL.

Does anyone have bandwidth to try it out before the apprentices get to it tomorrow? 馃檹

Most helpful comment

Items that should be different:

  1. when installing node modules replace mysql with pg (https://www.npmjs.com/package/pg)
  2. Table creation should be mostly the same:
CREATE DATABASE socka;
CREATE TABLE IF NOT EXISTS `players` (
  `id` SERIAL,
  `first_name` varchar(255) NOT NULL,
  `last_name` varchar(255) NOT NULL,
  `position` varchar(255) NOT NULL,
  `number` int(11) NOT NULL,
  `image` varchar(255) NOT NULL,
  `user_name` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
)
  1. When importing the database library into your app: const mysql = require('mysql') becomes const pg = require('pg')
  2. mysql.createConnection becomes .
const db = new pg.Client({ user: '<user>', host: '<host>', ...etc })
db.connect()

I think pretty much everything else remains the same

All 5 comments

Items that should be different:

  1. when installing node modules replace mysql with pg (https://www.npmjs.com/package/pg)
  2. Table creation should be mostly the same:
CREATE DATABASE socka;
CREATE TABLE IF NOT EXISTS `players` (
  `id` SERIAL,
  `first_name` varchar(255) NOT NULL,
  `last_name` varchar(255) NOT NULL,
  `position` varchar(255) NOT NULL,
  `number` int(11) NOT NULL,
  `image` varchar(255) NOT NULL,
  `user_name` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
)
  1. When importing the database library into your app: const mysql = require('mysql') becomes const pg = require('pg')
  2. mysql.createConnection becomes .
const db = new pg.Client({ user: '<user>', host: '<host>', ...etc })
db.connect()

I think pretty much everything else remains the same

Also worth noting that the tutorial doesn't cover installation of postgres or interacting with it via the command line. It pushes that into XAMPP or similar which includes a bundled database and phpmyadmin installation.

PostgreSQL should either be already done or tutorials to cover it should be added as well as using the CLI instead of the UI provided by phpmyadmin.

picked up by risa

Consider: use an entirely different tutorial, such as Treehouse's "Using SQL and Node.js with Sequelize" https://teamtreehouse.com/library/using-sql-and-nodejs-with-sequelize

Why?

  • teaches CRUD, and you can see C, R, U, and D in the titles of the videos
  • teaches using an ORM
  • has videos
  • uses sqlite3, which everyone already has on their macs <--for next cohort, let's move this line item in the roadmap between "Relational Databases" and "Install Postgres"

Why not use this Sequelize tutorial from Treehouse tomorrow?

  • Does everyone have a Treehouse account? (Could always temporarily pair)
  • Does it use Express.js? Is that something we need here?
  • Did we want people to do it once specifically without an ORM, first???

I'll decide by the end of the day.

Option three: strike either of those tutorials completely, and instead use the "simple TODO app" in the Integration Testing topic outline beginning here: https://github.com/Techtonica/curriculum/blob/master/testing-and-tdd/integration-testing.md#guided-practice

Why would we do this?

  • create one new project instead of two new projects
  • more time to go deeper into one project (instead of spending time spinning up a new project twice in the same day)
  • it uses ElephantSQL and avoids PostgreSQL installation problems
  • TDD approach to building an API to practice what we preach

Why not?

  • We all installed PostgreSQL today!
  • Is adding testing while making their first API too much to throw in at a time?
Was this page helpful?
0 / 5 - 0 ratings

Related issues

alodahl picture alodahl  路  4Comments

vegetabill picture vegetabill  路  5Comments

hoserdude picture hoserdude  路  9Comments

alodahl picture alodahl  路  5Comments

alodahl picture alodahl  路  6Comments