{"id":19758048,"url":"https://github.com/paurkedal/episql","last_synced_at":"2025-06-27T06:38:33.647Z","repository":{"id":19995165,"uuid":"23262495","full_name":"paurkedal/episql","owner":"paurkedal","description":"SQL schema parser and code generator","archived":false,"fork":false,"pushed_at":"2023-12-18T16:23:45.000Z","size":494,"stargazers_count":29,"open_issues_count":1,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-01-15T07:30:26.468Z","etag":null,"topics":["code-generator","ocaml","sql","sql-schema-parser"],"latest_commit_sha":null,"homepage":"","language":"OCaml","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/paurkedal.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-08-23T17:57:21.000Z","updated_at":"2024-11-04T23:47:03.000Z","dependencies_parsed_at":"2022-07-22T03:46:55.973Z","dependency_job_id":"d8dad8ab-9052-4cfc-84b8-10c005c1cc52","html_url":"https://github.com/paurkedal/episql","commit_stats":null,"previous_names":[],"tags_count":39,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paurkedal%2Fepisql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paurkedal%2Fepisql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paurkedal%2Fepisql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paurkedal%2Fepisql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paurkedal","download_url":"https://codeload.github.com/paurkedal/episql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234835800,"owners_count":18894285,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["code-generator","ocaml","sql","sql-schema-parser"],"created_at":"2024-11-12T03:22:43.566Z","updated_at":"2025-01-20T18:27:15.893Z","avatar_url":"https://github.com/paurkedal.png","language":"OCaml","funding_links":[],"categories":[],"sub_categories":[],"readme":"# epiSQL - SQL schema parser and code generator\n\n## Synopsis\n\nepiSQL /ˈɛpɪˈsiːkwəl/ is an SQL schema parser and code generator.  It\nsupports a subset of SQL `CREATE`-statements with focus on PostgreSQL.  It\ncontains generators for\n\n  * [Caqti][], providing a persistence-style API with caching,\n  * XML, providing easy access for external applications to the schema, and\n  * Unix shells, providing a series of function calls for general ad-hoc use.\n\n## Caqti Persistence\n\n**Note**: This generator will likely be replaced with one providing an\nincompatible API, so don't use it for new projects.\n\nThis backend maps database rows to memory-cached objects, and provides an\ninterface to fetch, insert, update, and delete individual objects.  It is\nassumed that only one application access the cached tables.\n\nCache-coherent search functions limited to single-table queries are\nprovided, as well.\n\nDefinitions are only generated for tables which explicitly specifies a\nprimary key.  The primary key is used to address objects.\n\nIt is recommended to generate four separate files, e.g.\n\n``` sh\nepisql -g caqti-persist-types-mli -o foo_types.mli foo.sql\nepisql -g caqti-persist-types-ml  -o foo_types.ml  foo.sql\nepisql -g caqti-persist-mli -t Foo_types -o foo_functor.mli foo.sql\nepisql -g caqti-persist-ml  -t Foo_types -o foo_functor.ml  foo.sql\n```\n\nThe `Foo_types` module will contain pure types and related functions, which\nsupports deriving annotations (see `-deriving`).  The `Foo_functor` module\ncontains a functor which can be instantiated with caching and database\ntraits.  For more details see\n\n``` sh\nepisql -g caqti-persist-ml -help\n```\n\n## XML Output\n\nThe switch `-g xml` produces an XML dump of the database schema, making it\npossible for external software to extract information from the schema\nwithout parsing SQL.  E.g. this could be used to implement an alternative\ncode generator using an XSLT.\n\nThe above example translates to\n\n``` xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003cepisql\u003e\n  \u003ccreate-table name=\"testarea.note\"\u003e\n    \u003ccolumn name=\"note_id\" type=\"serial\" primary-key=\"true\"/\u003e\n    \u003ccolumn name=\"note\" type=\"text\" nullable=\"false\"/\u003e\n  \u003c/create-table\u003e\n\u003c/episql\u003e\n```\n\n## Shell Output\n\nUse `-g shell` to create a sequence of command invocations corresponding to\nthe table definitions.  E.g. the above example produce\n\n``` sh\nenter_create_table testarea.note\nadd_column testarea.note note_id 'serial' \"PRIMARY KEY\"\nadd_column testarea.note note 'text' \"NOT NULL\"\nleave_create_table testarea.note\n```\n\nThis is not meant as a permanent solution, but provides a quick way to\ninspect or generate unsupported code.  The XML generator described above\nprovides a more faithful representation and is more appropriate for external\napplications.\n\n\n[Caqti]: https://github.com/paurkedal/ocaml-caqti\n[Macaque]: http://ocsigen.org/macaque/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaurkedal%2Fepisql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpaurkedal%2Fepisql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaurkedal%2Fepisql/lists"}