Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Cascalog JDBCTap Example
(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
You can’t perform that action at this time.