Created
March 13, 2023 18:11
-
-
Save arnaudgeiser/0949fefdd16776cddbbea9952d99b9c5 to your computer and use it in GitHub Desktop.
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
(require '[next.jdbc :as jdbc]) | |
(import '[org.dbunit.database DatabaseConnection QueryDataSet]) | |
(import '[org.dbunit.dataset.xml FlatXmlDataSet]) | |
(let [db-conn (DatabaseConnection. (jdbc/get-connection db-spec)) | |
dataset (QueryDataSet. db-conn)] | |
(.addTable dataset "RESTAURANTS" "SELECT * FROM Restaurants") | |
(.addTable dataset "LIKES" "SELECT * FROM Likes WHERE FK_REST IN (SELECT NUMERO FROM Restaurants)") | |
(.addTable dataset "COMMENTAIRES" "SELECT * FROM Commentaires WHERE FK_REST IN (SELECT NUMERO FROM Restaurants)") | |
(.addTable dataset "NOTES" "SELECT * FROM Notes WHERE fk_comm IN (SELECT NUMERO FROM Commentaires WHERE FK_REST IN (SELECT NUMERO FROM Restaurants))") | |
(.addTable dataset "CRITERES_EVALUATION" "SELECT * FROM CRITERES_EVALUATION WHERE NUMERO IN (SELECT fk_crit FROM Notes WHERE fk_comm IN (SELECT NUMERO FROM Commentaires WHERE FK_REST IN (SELECT NUMERO FROM Restaurants)))") | |
(FlatXmlDataSet/write dataset (io/output-stream "/tmp/export2.xml"))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment