diff --git a/changelog b/changelog
--- a/changelog
+++ b/changelog
@@ -1,2 +1,5 @@
+0.7.1
+* Add executable groundhog_inspector
+
 0.7.0
 * The first release
diff --git a/groundhog-inspector.cabal b/groundhog-inspector.cabal
--- a/groundhog-inspector.cabal
+++ b/groundhog-inspector.cabal
@@ -1,5 +1,5 @@
 name:            groundhog-inspector
-version:         0.7.0
+version:         0.7.1
 license:         BSD3
 license-file:    LICENSE
 author:          Boris Lykah <lykahb@gmail.com>
@@ -8,13 +8,25 @@
 description:     This library analyzes database tables and creates corresponding datatypes and their mappings for Groundhog <https://www.fpcomplete.com/user/lykahb/groundhog>. See examples at <https://github.com/lykahb/groundhog/tree/master/groundhog-inspector/examples>.
 category:        Database
 stability:       Experimental
-cabal-version:   >= 1.6
+cabal-version:   >= 1.8
 build-type:      Simple
 homepage:        http://github.com/lykahb/groundhog
 
 extra-source-files:
     changelog
 
+Flag sqlite
+   Description: analyze Slite
+   Default: True
+
+Flag postgresql
+   Description: analyze PostgreSQL
+   Default: False
+
+Flag mysql
+   Description: analyze MySQL
+   Default: False
+
 library
     build-depends:   base                     >= 4       && < 5
                    , bytestring               >= 0.9
@@ -34,3 +46,32 @@
 source-repository head
   type:     git
   location: git://github.com/lykahb/groundhog.git
+
+executable groundhog_inspector
+  hs-source-dirs: main
+  main-is:        Main.hs
+
+  ghc-options:
+    -Wall -rtsopts
+
+  build-depends:
+      base
+    , mtl                      >= 2.0
+    , cmdargs                  >= 0.10
+    , containers               >= 0.2
+    , bytestring               >= 0.9
+    , groundhog
+    , groundhog-th
+    , groundhog-inspector
+
+  if flag(sqlite)
+    build-depends: groundhog-sqlite
+    cpp-options: -DWITH_SQLITE
+
+  if flag(postgresql)
+    build-depends: groundhog-postgresql
+    cpp-options: -DWITH_POSTGRESQL
+
+  if flag(mysql)
+    build-depends: groundhog-mysql
+    cpp-options: -DWITH_MYSQL
diff --git a/main/Main.hs b/main/Main.hs
new file mode 100644
--- /dev/null
+++ b/main/Main.hs
@@ -0,0 +1,72 @@
+{-# LANGUAGE CPP, DeriveDataTypeable #-}
+
+module Main where
+
+import System.Console.CmdArgs
+import Control.Monad.Trans (MonadIO(..))
+import qualified Data.ByteString.Lazy.Char8 as B
+import qualified Data.Map as Map
+
+import Database.Groundhog.Generic.Migration (SchemaAnalyzer)
+import Database.Groundhog.TH (suffixNamingStyle)
+import Database.Groundhog.Inspector
+
+#if WITH_SQLITE
+import Database.Groundhog.Sqlite
+#endif
+#if WITH_POSTGRESQL
+import Database.Groundhog.Postgresql
+#endif
+#if WITH_MYSQL
+import Database.Groundhog.MySQL
+#endif
+
+data Args = Args {database :: String, connectionInfo :: String} deriving (Show, Data, Typeable)
+
+databases :: [String]
+databases =
+#if WITH_SQLITE
+  "sqlite":
+#endif
+#if WITH_POSTGRESQL
+  "postgresql":
+#endif
+#if WITH_MYSQL
+  "mysql":
+#endif
+  []
+
+sample :: Mode (CmdArgs Args)
+sample = cmdArgsMode $ Args { database = def &= argPos 0 &= typ (show databases) &= opt (head databases)
+              , connectionInfo = def &= argPos 1 &= typ "CONNECTION_STRING" }
+         &= summary "groundhog-inspector"
+         &= details ["Pass a name of a database. The connection string is an argument to with*Conn. "
+           , "MySQL connection string is \"ConnectInfo {...}\""]
+
+analyze :: (PersistBackend m, SchemaAnalyzer m, MonadIO m) => m ()
+analyze = do
+  tables <- collectTables (const True) Nothing
+  -- Analyze tables
+  let decs = generateData defaultDataCodegenConfig defaultReverseNamingStyle tables
+  mappings <- generateMapping defaultReverseNamingStyle tables
+  -- Print datatype declarations
+  liftIO $ mapM_ (putStrLn . showData) $ concat $ map (uncurry (:)) $ Map.elems $ decs
+  -- Remove parts of mapping that are defaults for the chosen naming style
+  let mappings' = Map.intersectionWith (minimizeMapping suffixNamingStyle . fst) decs mappings
+  -- Print mappings
+  liftIO $ B.putStrLn $ showMappings $ Map.elems mappings'
+
+main :: IO ()
+main = do
+  arg <- cmdArgsRun sample
+  case database arg of
+#if WITH_SQLITE
+    "sqlite" -> withSqliteConn (connectionInfo arg) $ runDbConn analyze
+#endif
+#if WITH_POSTGRESQL
+    "postgresql" -> withPostgresqlConn (connectionInfo arg) $ runDbConn analyze
+#endif
+#if WITH_MYSQL
+    "mysql" -> withMySQLConn (read $ connectionInfo arg) $ runDbConn analyze
+#endif
+    other -> fail $ "Unknown database: " ++ other
