{"id":21523338,"url":"https://github.com/jszafran/sqlcommatize","last_synced_at":"2025-03-17T17:42:43.680Z","repository":{"id":56743137,"uuid":"524495095","full_name":"jszafran/sqlcommatize","owner":"jszafran","description":"Utility tool that helps with wrapping copied column results with commas/commas + single quotes - so you can use them within IN clause.","archived":false,"fork":false,"pushed_at":"2022-08-21T13:36:13.000Z","size":33,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-24T05:08:17.634Z","etag":null,"topics":["go","golang","sql"],"latest_commit_sha":null,"homepage":"","language":"Go","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/jszafran.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-08-13T19:55:58.000Z","updated_at":"2022-08-26T18:34:47.000Z","dependencies_parsed_at":"2022-08-16T01:10:41.540Z","dependency_job_id":null,"html_url":"https://github.com/jszafran/sqlcommatize","commit_stats":null,"previous_names":["jszafran/go-sql-commas"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jszafran%2Fsqlcommatize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jszafran%2Fsqlcommatize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jszafran%2Fsqlcommatize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jszafran%2Fsqlcommatize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jszafran","download_url":"https://codeload.github.com/jszafran/sqlcommatize/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244080589,"owners_count":20394948,"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":["go","golang","sql"],"created_at":"2024-11-24T01:13:29.630Z","updated_at":"2025-03-17T17:42:43.655Z","avatar_url":"https://github.com/jszafran.png","language":"Go","readme":"# sqlcommatize\n\n## Why this project was created?\n\nIf you work a lot with SQL then you probably often have a situation that you're \ncopying some column values (i.e. from SQL query result or Excel sheet) and then paste them into SQL IN clause.\n\nFor example you copy 3 rows from Excel that contains values 1, 2, 3.\n```sql\nSELECT * \nFROM foo\nWHERE 1=1\nAND ID IN (\n    -- \u003cthe list of IDs that you paste\u003e\n    1\n    2\n    3\n)\n```\n\nThis is not a valid SQL syntax though.\n\nIn order for your query to work, you'll need to delimit your records with commas.\n```sql\nSELECT * \nFROM foo\nWHERE 1=1\n  AND ID IN (\n    1,\n    2,\n    3\n)\n```\n\nIf `ID` is a string type, then you'll also need to wrap values with single quotes:\n```sql\nSELECT * FROM foo\nWHERE ID IN (\n    '1',\n    '2',\n    '3'\n)\n```\n\nHandling large number of records manually becomes very cumbersome quickly.\n\n`sqlcommatize` does the tedious work for you.\n\n## How does it work?\n`sqlcommatize` is a command-line tool that:\n* Reads the content of your clipboard\n* Adds commas (and optionally single quotes) to records\n* Pastes processed records back to clipboard\n\nIt is written in Golang and compiles to a single binary file.\nMultiplatform support (Linux, MacOS, Windows) is achieved thanks to `golang.design/x/clipboard` module.\n\n\n\n## Usage\n\nCommand\n```\n./sqlcommatize --help\n```\n\nprints available flags:\n```\nUsage of sqlcommatize:\n  -leading_commas\n        Use leading commas for separating rows (trailing commas used by default).\n  -strings\n        Wraps rows with single quotes (for SQL strings).\n```\n### No arguments provided\nWhen you run the application without any arguments, it uses default arguments:\n* only commas are added (input is treated as numbers)\n* trailing commas styling is used\n\nFor input:\n```\n1\n2\n3\n```\n\nrunning\n\n```bash\n./sqlcommatize\n```\n\nproduces:\n\n```\n1,\n2,\n3\n```\n\n### `-strings` flag\n\n```bash\n./sqlcommatize -strings\n```\n\n`-strings` flag wraps each record with single quotes:\n\n```\n'1',\n'2',\n'3'\n```\n\nIf any records contains a single quotes, program replaces them with double single quotes:\n\n```\nWhat's up?\nFoo\nBar\n```\n\nwould be transformed into:\n\n```sql\n'What''s up?',\n'Foo',\n'Bar'\n```\n\n### `-leading_commas` flag\n`-leading_commas` changes the comma styling from trailing to leading:\n\n```\n1\n,2\n,3\n```\n\n### Keyboard shortcuts\nFor usage convenience, you can create 2 keyboard shortcuts:\n* one for numeric values `/path/to/sqlcommatize` (or optionally `/path/to/sqlcommatize -leading_commas` for leading commas)\n* one for string values `/path/to/sqlcommatize -strings` (`/path/to/sqlcommatize -leading_commas -strings`)\n\nand use them quickly whenever you need to paste some rows into SQL query.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjszafran%2Fsqlcommatize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjszafran%2Fsqlcommatize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjszafran%2Fsqlcommatize/lists"}