[Tutorial] How to Use MySQL or MariaDB with Node.js and Express

I think it’s similar in Postgres, but the syntax is a little different. Here are some examples for doing raw SQL queries in postgres and sqlite3.

For a bigger project, I would actually use something like Knex to connect to databases, because it offers database migrations and easier switching of databases.

I’ve heard recommendations for Objection.js (built on top of Knex) but I haven’t tried it. Sequelize is another one.