Q: Clojure: read metadata of a database I am trying to get metadata from an sqlite database. The main purpose for the moment was to get a list of tables.
Code below (from here: link):
(defn db-get-tables
"Demonstrate getting table info"
[]
(sql/with-connection db
   (into []
      (resultset-seq
       (-> (sql/connection)
           (.getMetaData)
           (.getTables nil nil nil (into-array ["TABLE" "VIEW"])))))))

This gives me a list of maps with metadata regarding the tables in the database. However, if I try to iterate this list (using 'for' or 'first') it gives me:
"Don't know how to create ISeq from proj00.operations.database$tables-list"

I believe that there must be an easy way to do this. But I just cannot find the right information on the web. Also, I cannot understand where that error is coming from.

A: It might be because the connection with the database is only open within the scope of "sql/with connection db". If I iterate through the collection like this with Microsoft SQL, I get an error that the connection is closed.
If you wrap the resultset-seq in a doall, this should be fixed. This breaks lazyness though in favor of getting all results into memory and being able to close the connection. If you want to keep lazyness, you should put the iteration within the "with-connection" scope, but you'll keep the connection open until you're done.
Also, you can generalize this function into supporting all metadata methods by making a macro of this (thanks to Verneri Åberg's answer to a question of mine):
(defmacro get-sql-metadata [db method & args] 
  `(with-connection 
    ~db 
    (doall 
      (resultset-seq 
        (~method 
          (.getMetaData (connection)) 
          ~@args)))))

So now you can call the metadata with the metadata method and its own parameters like so:
(get-sql-metadata db .getTables nil nil nil (into-array ["TABLE" "VIEW"]))
or
(get-sql-metadata db .getColumns nil nil nil nil)

Followup:
Created a testdatabase, connected, everything should work like this.
Leiningen
  (defproject sqlitetest "1.0.0-SNAPSHOT"
    :description "FIXME: write description"
    :dependencies [[org.clojure/clojure "1.3.0"]
                   [org.xerial/sqlite-jdbc "3.6.16"]
                   [org.clojure/java.jdbc "0.1.0"]])

Program
(ns sqlitetest
  (:use [clojure.java.jdbc]))

(def db { :classname "org.sqlite.JDBC"
          :subprotocol "sqlite"
          :subname "E:/temp/chinook.db"})

(defmacro get-sql-metadata [db method & args]
  `(with-connection
    ~db
    (doall
      (resultset-seq
        (~method
          (.getMetaData (connection))
          ~@args)))))

(def tables-list
  (get-sql-metadata db .getTables nil nil nil (into-array ["TABLE" "VIEW"])))

REPL
sqlitetest=>(map :table_name tables-list)
("SQLITE_SEQUENCE" "ALBUM" "ARTIST" "CUSTOMER" "EMPLOYEE" "GENRE" "INVOICE" "INVOICELINE" "MEDIATYPE" "PLAYLIST" "PLAYLISTTRACK" "TRACK")

sqlitetest=>(first tables-list)   
{:self_referencing_col_name nil, :table_name "SQLITE_SEQUENCE", :type_schem nil, :ref_generation nil, :table_type "TABLE", :table_schem nil, :table_cat nil, :type_cat nil, :type_name nil, :remarks nil}

Remark on your comment and answer to the question
The error is caused by doing defn instead of def over the table-list as in your comment. I run into the same error if I use defn.
