Drivers, not magic
Every language has a Postgres driver. The best ones (psycopg for Python, pg for Node, sqlx for Rust, pgx for Go, libpq for C) speak the wire protocol directly, support binary parameter encoding, and integrate with connection pools. ORMs and query builders all sit on top of these.
Connection strings
The standard URL form: postgresql://user:pass@host:5432/dbname?sslmode=require. Memorise the parts. The same string works in psql, in any driver, in pgAdmin, anywhere.
Always parameterise
Driver-level parameter binding is your primary defence against SQL injection. Never concatenate user input into a SQL string. Pass it as a parameter; the driver and the database handle escaping correctly.