On Wed, Jan 11, 2012 at 6:27 AM, jayvandal <s...@ida.net> wrote:
> What is the format error?

When you post a question, please post the exact error you get,
otherwise how are we supposed to know what "format error" you are
getting?

As usual, the code you show in the email cannot be the code you are
running since it is not well formed:

> (defn create-fruit []
> (sql/with-connection db
>  (sql/create-table :fruit
>    [:name "varchar(25)"]
>   [:appearance "varchar(25)"]
>   [:cost "integer(5)"]
>   [:id "float(2.3"))))

Looks like this should be:

      [:id "float(2.3)" ] )))

>  (defn insert-rows-fruit  []
>  (sql/with-connection db
>
>   (sql/insert-record :fruit

This line should not be here. Either you are inserting a single record
or you are inserting multiple rows.

>  (sql/insert-rows
>    :fruit
>    ["Apple" "red" 59 8.7]
>    ["Banana" "yellow" 29 92.2]
>    ["Peach" "fuzzy" 139 9.0]
>    ["Orange" "juicy" 89 88.6]))))

With that line removed, and the extra ) removed, your code works just fine:

> lein repl
REPL started; server listening on localhost port 12738
user=> (ns fruit.core)
nil
fruit.core=> (require 'fruit.core)
nil
fruit.core=> db
{:subprotocol "mysql", :classname "com.mysql.jdbc.Driver", :subname
"//localhost:3306/test", :user "root", :password "visual"}
fruit.core=> (defn create-fruit []
 (sql/with-connection db
  (sql/create-table :fruit
   [:name "varchar(25)"]
   [:appearance "varchar(25)"]
   [:cost "integer(5)"]
   [:id "float(2.3)" ] )))
#'fruit.core/create-fruit
fruit.core=> (defn insert-rows-fruit  []
 (sql/with-connection db
  (sql/insert-rows
   :fruit
   ["Apple" "red" 59 8.7]
   ["Banana" "yellow" 29 92.2]
   ["Peach" "fuzzy" 139 9.0]
   ["Orange" "juicy" 89 88.6])))
#'fruit.core/insert-rows-fruit
fruit.core=> (create-fruit)
(0)
fruit.core=> (insert-rows-fruit)
(1 1 1 1)
fruit.core=> (sql/with-connection db (sql/with-query-results rows
["select * from fruit"] (println rows)))
({:name Apple, :appearance red, :cost 59, :id 8.7} {:name Banana,
:appearance yellow, :cost 29, :id 92.2} {:name Peach, :appearance
fuzzy, :cost 139, :id 9.0} {:name Orange, :appearance juicy, :cost 89,
:id 88.6})
nil
fruit.core=>
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to