Book Image

Clojure Web Development Essentials

By : Ryan Baldwin
Book Image

Clojure Web Development Essentials

By: Ryan Baldwin

Overview of this book

Table of Contents (19 chapters)
Clojure Web Development Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Fetching albums from the database


In Chapter 7, Getting Started with the Database, we were introduced to YeSQL for interacting with our database. We used YeSQL to create an INSERT statement which added our new users to the database. Similarly, we can use YeSQL to SELECT records from the database. If you can do it in SQL, you can do it with YeSQL. And that's the beauty of YeSQL: it's just SQL. This allows us to open an SQL tool of our choice and experiment with our query until we get it right.

Writing the SQL query

For this next bit, we'll use the psql tool to verify our SQL. But you're free to use whatever SQL editor you have at your disposal. Take the following steps:

  1. Launch psql and connect to our database:

    # psql -U hipstr -d postgres -h localhost
    
  2. We can write our query at the PostgreSQL prompt. Any valid SQL is accepted at the prompt; we just need to terminate it with a semi-colon (;). Our feature wants to show a list of albums, the artist/s, and the release dates of those albums, all ordered...