Skip to content

Instantly share code, notes, and snippets.

@bendlas
Created January 10, 2011 16:05
Show Gist options
  • Save bendlas/772953 to your computer and use it in GitHub Desktop.
Save bendlas/772953 to your computer and use it in GitHub Desktop.
(ns gist
(:require [clojureql.core :as cql]))
(def schema-tables
(cql/select
(cql/table *db* :information_schema.tables)
(cql/where (= :table_schema "public"))))
(def table-columns
(cql/project
(cql/table server/*db* :information_schema.columns)
[:data_type]))
(def table-desc
(cql/join schema-tables table-columns :table_name))
@table-desc
;; throws (PG), since column :table_schema is ambigous
;; current workaround is to write the WHERE clause as (= :tables.table_schema "public")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment