Created
July 5, 2012 13:58
-
-
Save MrJaba/3053815 to your computer and use it in GitHub Desktop.
Cascalog JDBCTap Example
This file contains hidden or 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
(defn query-params [] | |
(into-array String ["?col1" "?col2"])) | |
(defn column-names [] | |
(into-array String ["col1" "col2"])) | |
; Becomes the 'where' part of the UPDATE statement - use primary key for example | |
(defn update-params [] | |
(into-array String ["?col1"])) | |
; Becomes the 'where' part of the UPDATE statement | |
(defn update-column-names [] | |
(into-array String ["col1"])) | |
(defn jdbc-tap [] | |
(let [scheme (JDBCScheme. (Fields. (query-params)) (column-names) nil (Fields. (update-params)) (update-column-names)) | |
table-desc (TableDesc. "table_name" (query-params) (column-names) (into-array String [])) | |
tap (JDBCTap. "jdbc:mysql://localhost:3306/burn?user=root&password=" "com.mysql.jdbc.Driver" table-desc scheme )] | |
tap)) | |
(defn write [] | |
(?<- (jdbc-tap) [?col1 ?col2] (tuple-source-tap ?col1 ?col2))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment