Aditya Gupta

Aditya Gupta

Aditya Gupta is a founding member and editor at CodeForGeek. He first found his way into tech by reading articles, and now writes approachable guides to Node.js security, authentication, AI tools, coding agents, and web scraping.

NodeJS MySQL Create Database

NodeJS MySQL Create Database

Create a MySQL database from Node.js with one query. The trick is connecting without naming a database first, running CREATE DATABASE IF NOT EXISTS, then verifying the schema exists. Here is how to do it with mysql2 and handle the…

NodeJS MySQL Select Unique

NodeJS MySQL Select Unique

I ran SELECT UNIQUE age FROM users on a table with a duplicated age. It returned 22, 17 and 15, the same rows SELECT DISTINCT returns. On MySQL 8 that statement stops before the table is read, because UNIQUE never…

Node.js MySQL Insert Record

Node.js MySQL Insert Record

I pointed a Node script at a MySQL table and the connection succeeded. The INSERT failed on a name containing an apostrophe. Pasting values into the SQL string holds until real data arrives, then a name like O’Brien ends the…

NodeJS MySQL Select Record

NodeJS MySQL Select Record

RowDataPacket is the name MySQL hands back to Node.js, and it is the line most readers get stuck on. This is the select step end to end, from a running MySQL server to a callback whose rows you can read.…

NodeJS MySQL Drop Table

NodeJS MySQL Drop Table

DROP TABLE crashed my Node process when I re-ran it without a guard, and the fix turns that crash into a warning. I built every code path below on Node 26.7.0 with mysql 2.18.1 and mysql2 3.24.4 against MariaDB 10.11.14.…