{"id":17658646,"url":"https://github.com/ruuda/squiller","last_synced_at":"2025-05-07T10:04:32.801Z","repository":{"id":66191278,"uuid":"504950372","full_name":"ruuda/squiller","owner":"ruuda","description":"Generate boilerplate from annotated SQL queries","archived":false,"fork":false,"pushed_at":"2025-04-06T17:35:25.000Z","size":412,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-07T10:03:25.708Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://docs.ruuda.nl/squiller/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ruuda.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"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}},"created_at":"2022-06-18T21:04:43.000Z","updated_at":"2025-04-06T17:35:29.000Z","dependencies_parsed_at":"2023-11-20T23:29:11.106Z","dependency_job_id":"6a37eb7c-d548-4426-83d5-ac96ec3d98f8","html_url":"https://github.com/ruuda/squiller","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruuda%2Fsquiller","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruuda%2Fsquiller/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruuda%2Fsquiller/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruuda%2Fsquiller/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ruuda","download_url":"https://codeload.github.com/ruuda/squiller/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252856551,"owners_count":21814858,"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":[],"created_at":"2024-10-23T15:27:51.610Z","updated_at":"2025-05-07T10:04:32.719Z","avatar_url":"https://github.com/ruuda.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Squiller\n\nSquiller generates boilerplate code from annotated SQL queries.\n\nWorking with SQL is often tedious, especially in statically typed settings. You\nneed to explicitly bind values to parameters, and extract the resulting values\nfor every column with the right type. Squiller can generate this boilerplate\ncode from a SQL file, based on annotations in comments.\n\n## Status\n\nSquiller is a work in progress, beta quality at best. Basic code generation for\nthe `rust-sqlite` target works, other targets are experimental and incomplete.\n\nIt was the author’s hypothesis that boilerplate code generation may be a nicer\nway to work with SQL than e.g. heavy reliance on proc macros in Rust. Squiller\nis used in [Musium](https://github.com/ruuda/musium) and so far it works well,\nbut it is too early to draw conclusions.\n\n## Example\n\nGiven the following input:\n\n```sql\n-- Look up a user by username.\n-- @query get_user_by_name(name: str) -\u003e? User\nselect id /* :i64 */, name /* :str */, email /* :str */\nfrom users\nwhere name = :name;\n```\n\nWhen targeting Rust and the `sqlite` crate, Squiller would generate roughly*:\n\n```rust\nstruct User {\n    id: i64,\n    name: String,\n    email: String,\n}\n\n/// Look up a user by username.\npub fn get_user_by_name(tx: \u0026mut Transaction, name: \u0026str) -\u003e Result\u003cOption\u003cUser\u003e\u003e {\n    let mut statement = tx.prepare(\n        r#\"\n        select id, name, email\n        from users\n        where name = :name;\n        \"#\n    )?;\n    statement.bind(1, name)?;\n    match statement.next()? {\n        State::Done =\u003e Ok(None),\n        State::Row =\u003e {\n            let result = User {\n                id: statement.read(0)?,\n                name: statement.read(1)?,\n                email: statement.read(2)?,\n            };\n            Ok(Some(result))\n        }\n    }\n}\n```\n\n\\* The example generated code is simplified to fit here, the actually generated\ncode consists of even more boilerplate.\n\n## Limitations\n\n * Squiller is not fully hygienic. This means that it can generate invalid code,\n   when user-specified names overlap with names that Squiller uses internally in\n   the generated code. Because the generated code is intended to be readable, it\n   should be easy to work around this by choosing different names in the input\n   SQL.\n\n * The generated code may not satisfy your style requirements. Squiller does try\n   to generate readable code with sensible indentation, but it does not break\n   long lines, and it may generate output that your code formatter disapproves\n   of. If this is an issue, simply run the output through your formatter of\n   choice.\n\n## Testing\n\nTo fuzz the parser:\n\n    cargo +nightly-2022-06-25 install cargo-fuzz --version 0.11.0\n    cargo +nightly-2022-06-25 fuzz run parse\n\nTo run the golden tests:\n\n    golden/run.py\n\nTo update golden tests, if a change is intentional:\n\n    golden/run.py --rewrite-output\n\nTo run a particular golden test:\n\n    golden/run.py golden/error/annotation_token_after_paren.test\n\n## License\n\nSquiller is licensed under the [Apache 2.0][apache2] license. Output of the\nprogram (code generated by Squiller) is not covered by this license. Please\ndo not open an issue if you disagree with the choice of license.\n\n[apache2]: https://www.apache.org/licenses/LICENSE-2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fruuda%2Fsquiller","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fruuda%2Fsquiller","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fruuda%2Fsquiller/lists"}