ANN: Groundhog-inspector, a tool for generating datatypes from database

Hello everyone, I am pleased to announce groundhog-inspector. It analyzes database schema and creates corresponding datatypes and mapping configuration for Groundhog. It works with PostgreSQL, MySQL, and Sqlite. Composite keys, constraints, references across schemas, and other details of schema are reflected in the output. Groundhog-inspector can be used as a library and provides a standalone tool for simple scenarios. Here is an example of the standalone tool usage. JSON mapping in the output was manually converted to YAML for brevity. $ sqlite3 dbfile "CREATE TABLE mytable (id INTEGER PRIMARY KEY NOT NULL, str VARCHAR NOT NULL, ref INTEGER references mytable)" $ groundhog_inspector sqlite dbfile data Mytable = Mytable {mytableStr :: String, mytableRef :: (Maybe (AutoKey Mytable))} - entity: "Mytable" dbName: "mytable" constructors: - name: "Mytable" fields: - name: "mytableStr" dbName: "str" - name: "mytableRef" dbName: "ref" * [Hackage] (http://hackage.haskell.org/package/groundhog-inspector) * [GitHub] ( https://github.com/lykahb/groundhog/tree/master/groundhog-inspector/examples ) I would be happy to answer the questions. Enjoy! Regards, Boris Lykah

Looks like a great idea. I tried it on one of my databases and got the following error: ** Exception: mkUniqueKeyPhantomName: (Just "public","itrd_test")uniques list must be not empty Do you know what that might mean? On Friday, December 5, 2014 4:07:34 AM UTC+11, Boris Lykah wrote:
Hello everyone,
I am pleased to announce groundhog-inspector. It analyzes database schema and creates corresponding datatypes and mapping configuration for Groundhog. It works with PostgreSQL, MySQL, and Sqlite. Composite keys, constraints, references across schemas, and other details of schema are reflected in the output. Groundhog-inspector can be used as a library and provides a standalone tool for simple scenarios.
Here is an example of the standalone tool usage. JSON mapping in the output was manually converted to YAML for brevity.
$ sqlite3 dbfile "CREATE TABLE mytable (id INTEGER PRIMARY KEY NOT NULL, str VARCHAR NOT NULL, ref INTEGER references mytable)"
$ groundhog_inspector sqlite dbfile
data Mytable = Mytable {mytableStr :: String, mytableRef :: (Maybe (AutoKey Mytable))}
- entity: "Mytable" dbName: "mytable" constructors: - name: "Mytable" fields: - name: "mytableStr" dbName: "str" - name: "mytableRef" dbName: "ref"
* [Hackage] (http://hackage.haskell.org/package/groundhog-inspector) * [GitHub] ( https://github.com/lykahb/groundhog/tree/master/groundhog-inspector/examples )
I would be happy to answer the questions. Enjoy!
Regards, Boris Lykah

Thanks for the report. Can you please send the SQL definition of
public.itrd_test? Looking at the code I think that it might have indexes
with expressions.
On Sat, Dec 27, 2014 at 12:43 AM,
Looks like a great idea. I tried it on one of my databases and got the following error:
** Exception: mkUniqueKeyPhantomName: (Just "public","itrd_test")uniques list must be not empty
Do you know what that might mean?
On Friday, December 5, 2014 4:07:34 AM UTC+11, Boris Lykah wrote:
Hello everyone,
I am pleased to announce groundhog-inspector. It analyzes database schema and creates corresponding datatypes and mapping configuration for Groundhog. It works with PostgreSQL, MySQL, and Sqlite. Composite keys, constraints, references across schemas, and other details of schema are reflected in the output. Groundhog-inspector can be used as a library and provides a standalone tool for simple scenarios.
Here is an example of the standalone tool usage. JSON mapping in the output was manually converted to YAML for brevity.
$ sqlite3 dbfile "CREATE TABLE mytable (id INTEGER PRIMARY KEY NOT NULL, str VARCHAR NOT NULL, ref INTEGER references mytable)"
$ groundhog_inspector sqlite dbfile
data Mytable = Mytable {mytableStr :: String, mytableRef :: (Maybe (AutoKey Mytable))}
- entity: "Mytable" dbName: "mytable" constructors: - name: "Mytable" fields: - name: "mytableStr" dbName: "str" - name: "mytableRef" dbName: "ref"
* [Hackage] (http://hackage.haskell.org/package/groundhog-inspector) * [GitHub] (https://github.com/lykahb/groundhog/tree/master/ groundhog-inspector/examples)
I would be happy to answer the questions. Enjoy!
Regards, Boris Lykah
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Regards, Boris

Is this what you are looking for? CREATE TABLE itrd_test ( crem_hash character varying(36) NOT NULL, session_hash character varying(36) NOT NULL, test_id character varying(36) NOT NULL, acquisition_type character varying(17) NOT NULL, test_type character varying(18) NOT NULL, offset_from_creation interval, flagged_electrodes character varying[], notes text NOT NULL, CONSTRAINT itrd_test_pkey PRIMARY KEY (test_id), CONSTRAINT itrd_test_crem_hash_fkey FOREIGN KEY (crem_hash) REFERENCES itrd_complaint (crem_hash) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION DEFERRABLE INITIALLY DEFERRED ) WITH ( OIDS=FALSE ); If not please let me know, my SQL knowledge is not great. On Sunday, December 28, 2014 2:49:24 AM UTC+11, Boris Lykah wrote:
Thanks for the report. Can you please send the SQL definition of public.itrd_test? Looking at the code I think that it might have indexes with expressions.
On Sat, Dec 27, 2014 at 12:43 AM,
javascript:> wrote: Looks like a great idea. I tried it on one of my databases and got the following error:
** Exception: mkUniqueKeyPhantomName: (Just "public","itrd_test")uniques list must be not empty
Do you know what that might mean?
On Friday, December 5, 2014 4:07:34 AM UTC+11, Boris Lykah wrote:
Hello everyone,
I am pleased to announce groundhog-inspector. It analyzes database schema and creates corresponding datatypes and mapping configuration for Groundhog. It works with PostgreSQL, MySQL, and Sqlite. Composite keys, constraints, references across schemas, and other details of schema are reflected in the output. Groundhog-inspector can be used as a library and provides a standalone tool for simple scenarios.
Here is an example of the standalone tool usage. JSON mapping in the output was manually converted to YAML for brevity.
$ sqlite3 dbfile "CREATE TABLE mytable (id INTEGER PRIMARY KEY NOT NULL, str VARCHAR NOT NULL, ref INTEGER references mytable)"
$ groundhog_inspector sqlite dbfile
data Mytable = Mytable {mytableStr :: String, mytableRef :: (Maybe (AutoKey Mytable))}
- entity: "Mytable" dbName: "mytable" constructors: - name: "Mytable" fields: - name: "mytableStr" dbName: "str" - name: "mytableRef" dbName: "ref"
* [Hackage] (http://hackage.haskell.org/package/groundhog-inspector) * [GitHub] (https://github.com/lykahb/groundhog/tree/master/ groundhog-inspector/examples)
I would be happy to answer the questions. Enjoy!
Regards, Boris Lykah
_______________________________________________ Haskell-Cafe mailing list Haskel...@haskell.org javascript: http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Regards, Boris
participants (2)
-
Boris Lykah
-
info@rotnetix.com