O'Reilly logo

Web Development with Clojure by Dmitri Sotnikov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Application Data Model

We’re now ready to start working on creating the application we outlined earlier. Since defining the data model is a prerequisite for all the following tasks, we’ll tackle it first.

Configuring the Database

Let’s create a new schema called gallery in the database. In PostgreSQL, create an admin user with the password set to admin, then run the following command to add the schema for our application.

 
CREATE​ ​DATABASE​ GALLERY OWNER admin;

Now that our database is ready to use, let’s look at how to connect to it. We can use clojure.java.jdbc to set up the Java Database Connectivity connection.

We’ll create a db namespace under models and set up our database connection there. For simplicity, let’s use the first method ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required