<commit_before>(ns note-server.database
  (:require [clojure.java.jdbc :as sql])
  )

(def database {:subprotocol "mysql"
               :subname "//127.0.0.1:3306/clojure_test"
               :user "root"
               :password ""})


; returns a hashmap
(defn query [id]
  ; TODO support any number of arguments
  (sql/query database
             [(str "select id, header, body
                   from note_test 
                   where id in (?,?)")
              (first id)
              (first (rest id))]))


; entry is a hashmap
(defn insert! [entry]
  (sql/insert! database :pass_test
               entry))
<commit_msg>backend database acces now allows for any number of notes requested at once<commit_after>(ns note-server.database
  (:require [clojure.java.jdbc :as sql])
  )

(def database {:subprotocol "mysql"
               :subname "//127.0.0.1:3306/clojure_test"
               :user "root"
               :password ""})


(defn query 
  "Returs a JSON list with objects, as a string"
  [id]
  (sql/query database
             (into [] 
                   (cons 
                     (str "select id, header, body
                          from note_test 
                          where id in ("
                          (apply str 
                                 (interpose "," 
                                            (repeat (count id)
                                                    "?")))
                          ")")
                     id))))


; entry is a hashmap
(defn insert! [entry]
  (sql/insert! database :pass_test
               entry))

{'fraction_non_alphanumeric': 0.10453400503778337, 'fraction_numerical': 0.012594458438287154, 'mean_word_length': 1.2380281690140844, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2858293', 'n_tokens_mistral': 447, 'n_tokens_neox': 415, 'n_words': 126}