{"id":15950149,"url":"https://github.com/akoutmos/sql_fmt","last_synced_at":"2025-04-05T04:08:44.367Z","repository":{"id":257812941,"uuid":"867906799","full_name":"akoutmos/sql_fmt","owner":"akoutmos","description":"Format and pretty print SQL queries","archived":false,"fork":false,"pushed_at":"2025-03-25T14:50:34.000Z","size":151,"stargazers_count":56,"open_issues_count":3,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-29T03:03:30.954Z","etag":null,"topics":["ecto","elixir","rust","sql"],"latest_commit_sha":null,"homepage":"https://hex.pm/packages/sql_fmt","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/akoutmos.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","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},"funding":{"github":["akoutmos"]}},"created_at":"2024-10-05T01:23:04.000Z","updated_at":"2025-03-27T11:08:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"c6539b81-44e1-492b-843c-a98c51cffa0d","html_url":"https://github.com/akoutmos/sql_fmt","commit_stats":{"total_commits":45,"total_committers":2,"mean_commits":22.5,"dds":0.0444444444444444,"last_synced_commit":"122ca3772cd9d527516e93412a6fd91dea2032c7"},"previous_names":["akoutmos/sql_fmt"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akoutmos%2Fsql_fmt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akoutmos%2Fsql_fmt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akoutmos%2Fsql_fmt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akoutmos%2Fsql_fmt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/akoutmos","download_url":"https://codeload.github.com/akoutmos/sql_fmt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247284944,"owners_count":20913704,"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":["ecto","elixir","rust","sql"],"created_at":"2024-10-07T12:58:20.627Z","updated_at":"2025-04-05T04:08:44.281Z","avatar_url":"https://github.com/akoutmos.png","language":"Elixir","readme":"\u003cp align=\"center\"\u003e\n  \u003cimg align=\"center\" width=\"25%\" src=\"guides/images/logo.png\" alt=\"sql_fmt Logo\"\u003e\n  \u003cimg align=\"center\" width=\"35%\" src=\"guides/images/logo_name.png\" alt=\"sql_fmt title\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  Format and pretty print SQL queries\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://hex.pm/packages/sql_fmt\"\u003e\n    \u003cimg alt=\"Hex.pm\" src=\"https://img.shields.io/hexpm/v/sql_fmt?style=for-the-badge\"\u003e\n  \u003c/a\u003e\n\n  \u003ca href=\"https://github.com/akoutmos/sql_fmt/actions\"\u003e\n    \u003cimg alt=\"GitHub Workflow Status (master)\"\n    src=\"https://img.shields.io/github/actions/workflow/status/akoutmos/sql_fmt/main.yml?label=Build%20Status\u0026style=for-the-badge\u0026branch=master\"\u003e\n  \u003c/a\u003e\n\n  \u003ca href=\"https://coveralls.io/github/akoutmos/sql_fmt?branch=master\"\u003e\n    \u003cimg alt=\"Coveralls master branch\" src=\"https://img.shields.io/coveralls/github/akoutmos/sql_fmt/master?style=for-the-badge\"\u003e\n  \u003c/a\u003e\n\n  \u003ca href=\"https://github.com/sponsors/akoutmos\"\u003e\n    \u003cimg alt=\"Support the project\" src=\"https://img.shields.io/badge/Support%20the%20project-%E2%9D%A4-lightblue?style=for-the-badge\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\u003cbr\u003e\n\n# Contents\n\n- [Installation](#installation)\n- [Example Output](#example-output)\n- [Mix Formatter](#mix-formatter)\n- [Supporting SqlFmt](#supporting-sqlfmt)\n- [Attribution](#attribution)\n\n## Installation\n\n[Available in Hex](https://hex.pm/packages/sql_fmt), the package can be installed by adding `sql_fmt` to your list of\ndependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:sql_fmt, \"~\u003e 0.4.0\"}\n  ]\nend\n```\n\nDocumentation can be found at [https://hexdocs.pm/sql_fmt](https://hexdocs.pm/sql_fmt).\n\n## Example Output\n\nAfter setting up SqlFmt in your application you can use the SqlFmt functions in order to format queries. Here are a\ncouple examples of queries with having parameters inline and with passing in the parameters separately:\n\n```elixir\niex(1)\u003e {:ok, formatted_sql} = SqlFmt.format_query(\"select * from businesses where id in ('c6f5c5f1-a1fc-4c9a-91f7-6aa40f1e233d', 'f339d4ce-96b6-4440-a541-28a0fb611139');\")\n{:ok, \"SELECT\\n  *\\nFROM\\n  businesses\\nWHERE\\n  id IN (\\n    'c6f5c5f1-a1fc-4c9a-91f7-6aa40f1e233d',\\n    'f339d4ce-96b6-4440-a541-28a0fb611139'\\n  );\"}\n\niex(2)\u003e IO.puts(formatted_sql)\nSELECT\n  *\nFROM\n  businesses\nWHERE\n  id IN (\n    'c6f5c5f1-a1fc-4c9a-91f7-6aa40f1e233d',\n    'f339d4ce-96b6-4440-a541-28a0fb611139'\n  );\n:ok\n```\n\n```elixir\niex(1)\u003e {:ok, formatted_sql} = SqlFmt.format_query_with_params(\"select * from help where help.\\\"col\\\" in $1;\", [\"'asdf'\"])\n{:ok, \"SELECT\\n  *\\nFROM\\n  help\\nWHERE\\n  help.\\\"col\\\" IN 'asdf';\"}\n\niex(2)\u003e IO.puts(formatted_sql)\nSELECT\n  *\nFROM\n  help\nWHERE\n  help.\"col\" IN 'asdf';\n:ok\n```\n\nBe sure to checkout the HexDocs as you can also provide formatting options to the functions to tailor the output to your\nliking.\n\n## Mix Formatter\n\nSqlFmt also provides you with the `~SQL` sigil that can be used to format SQL via Mix Formatter plugin. To set up the\nMix Formatter plugin, simply install this package and add update your `.formatter.exs` file as follows:\n\n```elixir\n[\n  plugins: [SqlFmt.MixFormatter],\n  inputs: [\"**/*.sql\"],\n  # ...\n]\n```\n\nWith this configuration, the SqlFmt Mix Format plugin will now format all `~SQL` sigils and all files ending in `.sql`.\nThis can be particularly useful in Ecto migrations where you have large `execute` statements and you want to make sure\nthat your code is readable. Check out the `SqlFmt.MixFormatter` module docs for more information.\n\n## Supporting SqlFmt\n\nIf you rely on this library help you debug your Ecto/SQL queries, it would much appreciated if you can give back\nto the project in order to help ensure its continued development.\n\nCheckout my [GitHub Sponsorship page](https://github.com/sponsors/akoutmos) if you want to help out!\n\n### Gold Sponsors\n\n\u003ca href=\"https://github.com/sponsors/akoutmos/sponsorships?sponsor=akoutmos\u0026tier_id=58083\"\u003e\n  \u003cimg align=\"center\" height=\"175\" src=\"guides/images/your_logo_here.png\" alt=\"Support the project\"\u003e\n\u003c/a\u003e\n\n### Silver Sponsors\n\n\u003ca href=\"https://github.com/sponsors/akoutmos/sponsorships?sponsor=akoutmos\u0026tier_id=58082\"\u003e\n  \u003cimg align=\"center\" height=\"150\" src=\"guides/images/your_logo_here.png\" alt=\"Support the project\"\u003e\n\u003c/a\u003e\n\n### Bronze Sponsors\n\n\u003ca href=\"https://github.com/sponsors/akoutmos/sponsorships?sponsor=akoutmos\u0026tier_id=17615\"\u003e\n  \u003cimg align=\"center\" height=\"125\" src=\"guides/images/your_logo_here.png\" alt=\"Support the project\"\u003e\n\u003c/a\u003e\n\n## Attribution\n\n- The logo for the project is an edited version of an SVG image from the [unDraw project](https://undraw.co/).\n- The SqlFmt library leans on the Rust library [sqlformat-rs](https://github.com/shssoichiro/sqlformat-rs) for SQL\n  statement formatting.\n","funding_links":["https://github.com/sponsors/akoutmos","https://github.com/sponsors/akoutmos/sponsorships?sponsor=akoutmos\u0026tier_id=58083","https://github.com/sponsors/akoutmos/sponsorships?sponsor=akoutmos\u0026tier_id=58082","https://github.com/sponsors/akoutmos/sponsorships?sponsor=akoutmos\u0026tier_id=17615"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakoutmos%2Fsql_fmt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fakoutmos%2Fsql_fmt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakoutmos%2Fsql_fmt/lists"}