{"id":22833112,"url":"https://github.com/lithdew/sqlutil","last_synced_at":"2025-10-17T23:04:24.626Z","repository":{"id":57522484,"uuid":"253062181","full_name":"lithdew/sqlutil","owner":"lithdew","description":"Utilities for working with SQL in Go.","archived":false,"fork":false,"pushed_at":"2020-05-08T16:54:41.000Z","size":16,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-06T07:24:36.400Z","etag":null,"topics":["golang","sql"],"latest_commit_sha":null,"homepage":null,"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/lithdew.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":"2020-04-04T17:45:15.000Z","updated_at":"2020-05-08T16:54:44.000Z","dependencies_parsed_at":"2022-09-05T09:51:21.630Z","dependency_job_id":null,"html_url":"https://github.com/lithdew/sqlutil","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lithdew%2Fsqlutil","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lithdew%2Fsqlutil/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lithdew%2Fsqlutil/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lithdew%2Fsqlutil/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lithdew","download_url":"https://codeload.github.com/lithdew/sqlutil/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246404023,"owners_count":20771549,"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":["golang","sql"],"created_at":"2024-12-12T21:11:53.430Z","updated_at":"2025-10-17T23:04:19.595Z","avatar_url":"https://github.com/lithdew.png","language":"Go","readme":"# sqlutil\n\n[![MIT License](https://img.shields.io/apm/l/atomic-design-ui.svg?)](LICENSE)\n[![go.dev reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go\u0026logoColor=white\u0026style=flat-square)](https://pkg.go.dev/github.com/lithdew/sqlutil)\n[![Discord Chat](https://img.shields.io/discord/697002823123992617)](https://discord.gg/HZEbkeQ)\n\nUtilities for working with SQL in Go.\n\n- Append an opinionated UTF-8 string representation of an `interface{}` to a byte slice, with byte slices being encoded into RFC-4648 Base64.\n- Convert `*sql.Rows` into JSON with minimal allocations.\n- Convert `*sql.Rows` into CSV with minimal allocations.\n- Parse/evaluate SQL statements with named parameters.\n\n## Example\n\nGiven the SQL query:\n\n```sqlite\nCREATE TABLE test (id integer primary key autoincrement, name varchar);\n\nINSERT INTO test (name) VALUES ('a');\nINSERT INTO test (name) VALUES ('b');\nINSERT INTO test (name) VALUES ('c');\nINSERT INTO test (name) VALUES ('d');\n\nSELECT * FROM test;\n```\n\n`sqlutil.RowsToJSON` would yield:\n\n```json\n[\n  {\n    \"id\": 1,\n    \"name\": \"a\"\n  },\n  {\n    \"id\": 2,\n    \"name\": \"b\"\n  },\n  {\n    \"id\": 3,\n    \"name\": \"c\"\n  },\n  {\n    \"id\": 4,\n    \"name\": \"d\"\n  }\n]\n```\n\n`sqlutil.RowsToCSV` would yield:\n\n```csv\nid,name\n1,\"a\"\n2,\"b\"\n3,\"c\"\n4,\"d\"\n```\n\n\n## Benchmarks\n\n```\ngo test -bench=. -benchmem -benchtime=10s\n\ngoos: linux\ngoarch: amd64\npkg: github.com/lithdew/sqlutil\nBenchmarkRowsToJSON-8            1213502              9531 ns/op             584 B/op         27 allocs/op\nBenchmarkRowsToCSV-8             1268085              9991 ns/op             584 B/op         27 allocs/op\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flithdew%2Fsqlutil","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flithdew%2Fsqlutil","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flithdew%2Fsqlutil/lists"}