Querying PostgreSQL from Node
5 min read
Module Overview
What You’ll Learn
- Write parameterized SQL queries from Node.js
- Prevent SQL injection by never concatenating user input into a query
- Run multi-step database operations safely inside a transaction
💡 Why this module matters: Connecting to PostgreSQL (Module 1) is only useful once real queries can be run against it, safely. This module covers reading and writing data with raw SQL, the foundation every ORM in this course is eventually built on top of.
What’s Covered
- SELECT, INSERT, UPDATE, DELETE, writing and running real SQL from a Node.js script.
- Parameterized queries, passing values safely instead of building query strings by hand.
- SQL injection, what it is, and why parameterized queries prevent it.
- Transactions, grouping multiple queries so they succeed or fail together.
Hands-On
By the end of this module, you’ll have written safe, parameterized SQL queries against a real PostgreSQL database, and run a multi-step operation inside a transaction.
Next module: introducing an ORM, and what Prisma actually does with all of this underneath.