liveBook · Manning

Psql

As explained in Build Python Web Apps with Streamlit

psql is PostgreSQL's interactive command-line client for issuing SQL statements and database-administration commands.

psql is PostgreSQL’s interactive command-line client. Use it to connect to a database, enter SQL statements, inspect tables, and perform database-administration tasks. After installing PostgreSQL, make the psql command available in your terminal or invoke it with its full installation path. section 8.2.3

A practical psql workflow moves from connection to database setup and inspection:

  • Connect as the default administrative user with psql -U postgres -d postgres. section 8.2.3
  • Create a separate user, grant it CREATEDB, and connect using that account. section 8.2.3
  • Create a database, switch to it with \c, and confirm the active psql prompt. section 8.2.3
  • Run SQL to create tables, insert records, query rows, update values, delete records, and inspect tables with \dt. section 8.2.4

Connecting to an application database

After creating haikudb for the application, connect directly with psql -U haiku_lord -d haikudb. At the resulting prompt, CREATE TABLE, INSERT, SELECT, UPDATE, and DELETE statements operate on that database. Use \dt to list its tables and verify that setup succeeded. section 8.2.3 section 8.2.4

psql -U postgres -d postgres

Use the connection command as the starting point for an interactive psql session. section 8.2.3

How Build Python Web Apps with Streamlit covers it

How deep it goes
Covers installation paths, user and database setup, table inspection, and basic SQL operations without deeper PostgreSQL internals.
Examples
Uses haikudb, the haiku_lord user, users and haikus tables, and SQL queries against sample haiku records.
What it assumes
Assumes a PostgreSQL installation and terminal access while teaching connection commands and introductory SQL from basic operations.
What you can do after
Operate/configure PostgreSQL locally by connecting to databases, creating tables, running CRUD statements, and checking results.
How it connects
Links PostgreSQL with SQL, database schemas, tables, users, permissions, and CRUD operations.

Also explained in

Compare how 3 books explain psql →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build Python Web Apps with Streamlit. The section links point to the parts of the book it draws on.