Schedule > 9. Databases and Object Relational Mappings
Tue, Oct 31
Readings & References
PostgreSQL Reference
- About PostgreSQL
- psql commands (command line)
- Querying a Table
- Joins Between Tables
- Aggregate Functions
- Inserts
- Updates
- Deletions
SQLAlchemy Reference
PostgreSQL Administrative Commands
To enter the postgreSQL shell, type: psql -U postgres
(connecting as the postgres superuser). Once you’re in the psql shell, try using the following commands:
Command | Explanation | Example |
---|---|---|
\q |
Exits the psql shell | |
\l |
Lists all the available databases | |
\c <dbname> <username> |
Connect to specific database | \c photo_app_tutorial postgres |
\dt |
Lists all of the tables in the database you’re connected to | |
\d <table_name> |
Describes the structure (i.e., “schema”) of a table | \d posts |
\du |
List all users and their roles | |
space bar | If you query data in a table that has multiple pages, the space bar will show you the next set of records. | |
q | If you query data in a table that has multiple pages, and you want to go back to the psql prompt. |
Slides
- Lecture 9: Intro to Relational Databases & ORMs
Activities
- Today’s Repo: https://github.com/csci338/orm-demo