On Wed, Feb 25, 2015 at 1:35 PM, Cecil Westerhof <cldwester...@gmail.com>
wrote:

> 2015-02-25 19:23 GMT+01:00 Aaron Cohen <aa...@assonance.org>:
>
>> On Wed, Feb 25, 2015 at 1:08 PM, Cecil Westerhof <cldwester...@gmail.com>
>> wrote:
>>
>>>
>>>
>>> 2015-02-25 18:14 GMT+01:00 Andy Fingerhut <andy.finger...@gmail.com>:
>>>
>>>> doseq does not have anything precisely like C/Java/Perl/etc.'s 'break'
>>>> or 'continue'.  The closest thing might be the :while keyword.  You can see
>>>> some one example of its use near the end of the examples on this page:
>>>> http://clojuredocs.org/clojure.core/doseq
>>>>
>>>> The best way I know to get such behavior is to use Clojure's loop,
>>>> where if/when/whatever-conditional-statements-you-wish can used to control
>>>> explicitly to do another loop iteration using recur, or not.
>>>>
>>>
>>> ​I made the following with loop:
>>>     (defn do-show-table
>>>       [table]
>>>       (loop [all-tables (show-tables db-spec)]
>>>         (let [this-table (get (first all-tables) :table_name)]
>>>           (if (= all-tables ())
>>>               (printf "Table not found: %s\n" table)
>>>             (if (= (lower-case table) (lower-case this-table))
>>>                 (let [format "%-20s %-30s %-5s %-5s %-20s\n"]
>>>                   (printf "Table %s:\n" table)
>>>                   (printf format "Field" "Type" "Null?" "Key" "Default")
>>>                   (doseq [{:keys [field type null key default]}
>>>                          (jdbc/query db-spec [(str "SHOW COLUMNS FROM "
>>> table)])]
>>>
>>
>> Please don't get into the habit of doing db queries like this, you're one
>> "Little Bobby Tables" away from an sql injection. In this case you should
>> do (jdbc/query db-spec ["SHOW COLUMNS FROM ?" table]).
>>
>
> ​That gives:
>     JdbcSQLException Syntax error in SQL statement "SHOW COLUMNS FROM ?";
> expected "identifier"; SQL statement:
>     SHOW COLUMNS FROM ? [42001-184]  org.h2.engine.SessionRemote.done
> (SessionRemote.java:622)
> ​
>
> ​That is why I do it in this way. As I understood it this has to do with
> that with a 'show columns from' the table can not be supplied. (I first
> tried Yesql, only when that did not work I went to JDBC.)​
>
>

I see, sorry to jump the gun and be incorrect while doing so.

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to