-
Notifications
You must be signed in to change notification settings - Fork 1
Configuration
- Database
- [Server] (#server)
- [Routes] (#routes)
mysql -u sortnight -p sortnight
Once connected to the database server you can create the sortnight database:
CREATE DATABASE sortnight;
USE sortnight;
Once you have a sortnight database, and you're connected to the database server.
Then create a sortnight user and give it access to the database. The user name is: sortnight, and it's password is "secret".
CREATE USER 'sortnight'@'localhost';
SET PASSWORD FOR 'sortnight'@'localhost' = PASSWORD('secret');
GRANT ALL ON sortnight.* TO 'sortnight'@'localhost';
To add database date, use the db.sql file as source. Make sure that you connect to the database in the same folder as the db.sql file.
This is the folder you need to connect to mysql with resources
SOURCE db.sql
After you've created the tables, you'll need to run with the movies profile of the project.
lein with-profile movies run
This will run the function that reads the movies in movies.clj and adds them to the database.
If you have a jar file instead, sn-backend.database-SNAPSHOT-standalone.jar. Position yourself in the database-generation folder and run the jar file.
Our database config looks like this:
(defdb ^{:dynamic false} db (mysql {:db "sortnight"
:user "sortnight"
:password "secret"
:host "localhost"
:port "3306"
:delimiters ""}))
Make sure your database has a sortnight user, with the password secret. And that your mysql server is running on port 3306. The defdb method is from SQLKorma.
Change the config in db.clj
We use the Jetty adapter and run it on port 3000.
(defn -main
"Main method for the server, runs a jetty server on port 3000 with our app handler" []
(run-jetty #'app {:port 3000}))
Change the config in core.clj
The routes of the server can be found in core