Yes you can get PostgreSQL running on Windows 10 or Windows 11 without summoning a ritual or a VM. This guide will walk you through downloading the official installer setting a superuser password installing pgAdmin and connecting from NodeJS and Python. Keep the default port 5432 unless you enjoy port conflicts.
Head to the PostgreSQL download page and grab the Windows installer for the stable release. Pick the architecture that matches your PC and save the installer somewhere you can find again when you forget where you put things.
pgAdmin gives you a GUI so you do less typing and more clicking. StackBuilder can add drivers and extensions if a project insists on having them. Most optional components are optional in name and avoidable in practice.
Open the Services app and confirm the PostgreSQL service is running. If you prefer the command line try:
psql -U postgres
Use host localhost port 5432 user postgres and the password you set. If psql connects you passed the first test. If the server is not running check the Windows Event Viewer or the PostgreSQL log file in the data directory.
Install the popular client and use environment variables so your secrets do not end up in source control.
npm install pg
# example runtime env for one off test
PGHOST=localhost PGUSER=postgres PGPASSWORD=yourpass PGPORT=5432 node test.js
# test.js
(async function() {
const { Client } = require('pg')
const client = new Client(process.env.DATABASE_URL || process.env.PGHOST)
await client.connect()
const res = await client.query('SELECT version()')
console.log(res.rows)
await client.end()
})()
Use a proper connection string in production and store it in a secrets manager or an env file that never gets checked in.
psycopg is the modern choice for Python. Install it and use a simple connection string.
pip install psycopg[binary]
import psycopg
conn = psycopg.connect('host=localhost dbname=postgres user=postgres password=yourpass port=5432')
cur = conn.cursor()
cur.execute('SELECT version()')
print(cur.fetchone())
cur.close()
conn.close()
You now have PostgreSQL installed on Windows and can query it from pgAdmin NodeJS and Python. It is stable battle tested and slightly smug about ACID properties. Back up the data directory or your future self will send you a very passive aggressive email.
I know how you can get Azure Certified, Google Cloud Certified and AWS Certified. It's a cool certification exam simulator site called certificationexams.pro. Check it out, and tell them Cameron sent ya!
This is a dedicated watch page for a single video.