-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
attempt to put reviews in a mysql database
- Loading branch information
Tom Brennan
committed
Jul 19, 2019
1 parent
71489d3
commit 27e492e
Showing
9 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
e3f73bca |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
CREATE TABLE IF NOT EXISTS shows ( | ||
imdb_id VARCHAR(255), | ||
show_id INT AUTO_INCREMENT, | ||
title VARCHAR(255) NOT NULL, | ||
runtime VARCHAR(255), | ||
imdb_rating VARCHAR(255), | ||
metascore VARCHAR(255), | ||
imdb_votes VARCHAR(255), | ||
type VARCHAR(255), | ||
genre VARCHAR(255), | ||
plot TEXT | ||
) | ||
|
||
|
||
INSERT INTO shows (imdb_id, show_id, title) | ||
VALUES (1, 2, 3); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package review; | ||
|
||
import org.springframework.data.repository.CrudRepository; | ||
|
||
public interface ReviewRepository extends CrudRepository<Review, String> { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package review; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class ReviewService { | ||
|
||
@Autowired | ||
private ReviewRepository reviewRepository; | ||
|
||
public void getAll(){ | ||
reviewRepository.findAll().forEach(review -> System.out.println(review.toString())); | ||
} | ||
|
||
public Review getReview(String id){ | ||
return reviewRepository.findById(id).get(); | ||
} | ||
|
||
public void addReview(Review review){ | ||
reviewRepository.save(review); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
spring.jpa.hibernate.ddl-auto=create | ||
spring.datasource.url=jdbc:mysql://localhost:3306/reviewdb | ||
spring.datasource.username=springuser | ||
spring.datasource.password=ThePassword |