{"id":27969187,"url":"https://github.com/future-architect/go-twowaysql","last_synced_at":"2025-08-31T17:47:29.986Z","repository":{"id":37936932,"uuid":"403457384","full_name":"future-architect/go-twowaysql","owner":"future-architect","description":"2-Way-SQL Go implementation","archived":false,"fork":false,"pushed_at":"2023-03-20T05:51:54.000Z","size":206,"stargazers_count":13,"open_issues_count":9,"forks_count":4,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-06-27T18:43:45.702Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","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/future-architect.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-09-06T02:06:31.000Z","updated_at":"2024-12-25T12:40:29.000Z","dependencies_parsed_at":"2024-06-19T04:00:40.039Z","dependency_job_id":null,"html_url":"https://github.com/future-architect/go-twowaysql","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/future-architect/go-twowaysql","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/future-architect%2Fgo-twowaysql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/future-architect%2Fgo-twowaysql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/future-architect%2Fgo-twowaysql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/future-architect%2Fgo-twowaysql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/future-architect","download_url":"https://codeload.github.com/future-architect/go-twowaysql/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/future-architect%2Fgo-twowaysql/sbom","scorecard":{"id":414674,"data":{"date":"2025-08-11","repo":{"name":"github.com/future-architect/go-twowaysql","commit":"04616b794170dbe13e2a95f8d8865788e67668d8"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.4,"checks":[{"name":"Code-Review","score":8,"reason":"Found 11/13 approved changesets -- score normalized to 8","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/test.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Pinned-Dependencies","score":3,"reason":"dependency not pinned by hash detected -- score normalized to 3","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/future-architect/go-twowaysql/test.yml/master?enable=pin","Warn: containerImage not pinned by hash: Dockerfile:1: pin your Docker image by updating golang:1.19 to golang:1.19@sha256:3025bf670b8363ec9f1b4c4f27348e6d9b7fec607c47e401e40df816853e743a","Info:   0 out of   1 GitHub-owned GitHubAction dependencies pinned","Info:   1 out of   1 goCommand dependencies pinned","Info:   0 out of   1 containerImage dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 28 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"16 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GO-2024-2606 / GHSA-7jwh-3vrq-q3m8 / GHSA-mrww-27vc-gghv","Warn: Project is vulnerable to: GO-2024-2605 / GHSA-m7wr-2xf7-cm9p","Warn: Project is vulnerable to: GO-2023-2402 / GHSA-45x7-px36-x8w8","Warn: Project is vulnerable to: GO-2024-3321 / GHSA-v778-237x-gjrc","Warn: Project is vulnerable to: GO-2025-3487 / GHSA-hcg3-q754-cr77","Warn: Project is vulnerable to: GO-2022-0969 / GHSA-69cg-p879-7622","Warn: Project is vulnerable to: GO-2022-1144 / GHSA-xrjj-mj9h-534m","Warn: Project is vulnerable to: GO-2023-1571 / GHSA-vvpx-j8f3-3w6h","Warn: Project is vulnerable to: GO-2023-1988 / GHSA-2wrh-6pvc-2jm9","Warn: Project is vulnerable to: GO-2023-2102 / GHSA-4374-p667-p6c8","Warn: Project is vulnerable to: GHSA-qppj-fm5r-hxr3","Warn: Project is vulnerable to: GO-2024-2687 / GHSA-4v7x-pqxf-cx7m","Warn: Project is vulnerable to: GO-2024-3333","Warn: Project is vulnerable to: GO-2025-3503 / GHSA-qxp5-gwg8-xv66","Warn: Project is vulnerable to: GO-2025-3595 / GHSA-vvgc-356p-c3xw","Warn: Project is vulnerable to: GO-2022-1059 / GHSA-69ch-w2m2-3vjp"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-18T23:31:49.638Z","repository_id":37936932,"created_at":"2025-08-18T23:31:49.638Z","updated_at":"2025-08-18T23:31:49.638Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273018115,"owners_count":25031596,"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","status":"online","status_checked_at":"2025-08-31T02:00:09.071Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":"2025-05-07T21:08:55.796Z","updated_at":"2025-08-31T17:47:29.943Z","avatar_url":"https://github.com/future-architect.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# twowaysql\n![test](https://github.com/future-architect/go-twowaysql/actions/workflows/test.yml/badge.svg)\n\n\n2-Way-SQL Go implementation\n\n## Installation\n\n```\ngo get github.com/future-architect/go-twowaysql\n```\n\n## Usage\n\nTODO Below is an example which shows some common use cases for twowaysql. \n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"log\"\n\n\t\"github.com/future-architect/go-twowaysql\"\n\t\"github.com/jmoiron/sqlx\"\n\t_ \"github.com/jackc/pgx/v4/stdlib\"\n)\n\ntype Person struct {\n\tEmpNo     int    `db:\"employee_no\"`\n\tDeptNo    int    `db:\"dept_no\"`\n\tFirstName string `db:\"first_name\"`\n\tLastName  string `db:\"last_name\"`\n\tEmail     string `db:\"email\"`\n}\n\ntype Params struct {\n\tName     string `twowaysql:\"name\"`\n\tEmpNo    int    `twowaysql:\"EmpNo\"`\n\tMaxEmpNo int    `twowaysql:\"maxEmpNo\"`\n\tDeptNo   int    `twowaysql:\"deptNo\"`\n}\n\nfunc main() {\n\tctx := context.Background()\n\n\tdb, err := sqlx.Open(\"pgx\", \"user=postgres password=postgres dbname=postgres sslmode=disable\")\n\n\tdefer db.Close()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\ttw := twowaysql.New(db)\n\n\tvar people []Person\n\tvar params = Params{\n\t\tMaxEmpNo: 2000,\n\t\tDeptNo:   15,\n\t}\n\n\terr = tw.Select(ctx, \u0026people, `SELECT * FROM persons WHERE employee_no \u003c /*maxEmpNo*/1000 /* IF deptNo */ AND dept_no \u003c /*deptNo*/1 /* END */`, \u0026params)\n\tif err != nil {\n\t\tlog.Fatalf(\"select failed: %v\", err)\n\t}\n\n\tfmt.Printf(\"%#v\\n%#v\\n%#v\", people[0], people[1], people[2])\n\t//Person{EmpNo:1, DeptNo:10, FirstName:\"Evan\", LastName:\"MacMans\", Email:\"evanmacmans@example.com\"}\n\t//Person{EmpNo:3, DeptNo:12, FirstName:\"Jimmie\", LastName:\"Bruce\", Email:\"jimmiebruce@example.com\"}\n\t//Person{EmpNo:2, DeptNo:11, FirstName:\"Malvina\", LastName:\"FitzSimons\", Email:\"malvinafitzsimons@example.com\"}\n\n}\n```\n\n## CLI Tool\n\nCLI tool `twowaysql` provides helper functions about two way sql\n\n```\ngo install github.com/future-architect/go-twowaysql/...\n```\n\n### Database Connection\n\nTo connect database, *driver* and *source* strings are required. Driver is like `pgx` and source is `postgres://user:pass@host/dbname?sslmode=disable`.\n\nYou can pass them via options(`-d DRIVER`, `--driver=DRIVER`, `-c SOURCE`, `--source=SOURCE`) or by using `TWOWAYSQL_DRIVER`/`TWOWAYSQL_CONNECTION` environment variables.\n\nThis tool also read `.env` and `.env.local` files.\n\n### Execute SQL\n\n```\n$ twowaysql run -p first_name=Malvina testdata/postgres/sql/select_person.sql\n┌───────────────────────────────┬────────────┬────────────┐\n│ email                         │ first_name │ last_name  │\n╞═══════════════════════════════╪════════════╪════════════╡\n│ malvinafitzsimons@example.com │ Malvina    │ FitzSimons │\n└───────────────────────────────┴────────────┴────────────┘\n\nQuery takes 22.804166ms\n```\n\n* -p, --param=PARAM ...        Parameter in single value or JSON (name=bob, or {\"name\": \"bob\"})\n* -e, --explain                Run with EXPLAIN to show execution plan\n* -r, --rollback               Run within transaction and then rollback\n* -o, --output-format=default  Result output format (default, md, json, yaml)\n\n### Evaluate 2-Way-SQL\n\n```sh\n$ twowaysql eval -p first_name=Malvina testdata/postgres/sql/select_person.sql\n# Converted Source\n\nSELECT email, first_name, last_name FROM persons WHERE first_name=?/*first_name*/;\n\n# Parameters\n\n- Malvina\n```\n\n### Unittesting\n\n```sh\n$ twowaysql test testdata/postgres/sql/select_person.sql\n```\n\nTest code is written in Markdown with the following format:\n\n* Single level 2 heading with \"Test\" or \"Tests\" label that contains all tests\n* Each test has level 3 headings with \"Case:\" prefix and test name\n* Each test can have YAML as a test code with the following keys:\n\t* `fixtures`(optional): These contents are imported as a test data\n\t* `params`(optional): This is an parameter of two way SQL\n\t* `testQuery`(optional): This is an query SQL to access table to check result. If you omit this, test runner gets result from SQL itself.\n\t* `expect`: This is an expected result.\n\nFixtures and expect should be nested list(first line is header) or list of maps.\n\n~~~~md\n## Tests\n\n### Case: Query Evan Test\n\n```yaml\nfixtures:\n  persons:\n    - [employee_no, dept_no, first_name, last_name, email, created_at]\n    - [4, 13, Dan, Conner, dan@example.com, 2022-09-13 10:30:15]\nparams: { first_name: Dan }\nexpect:\n  - { email: dan@example.com, first_name: Dan } \n```\n~~~~\n\n### Customize CLI tool\n\nby default `twowaysql` integrated with the following drivers:\n\n* ``github.com/jackc/pgx/v4``\n* ``modernc.org/sqlite``\n* ``github.com/go-sql-driver/mysql``\n\nIf you want to add/remove [drivers](https://github.com/golang/go/wiki/SQLDrivers), create simple main package and call `cli.Main()`.\n\n```go\npackage main\n\nimport (\n\t_ \"github.com/sijms/go-ora/v2\" // Oracle\n\n\t\"github.com/future-architect/go-twowaysql/cli\"\n)\n\nfunc main() {\n\tcli.Main()\n}\n```\n\n## License\n\nApache License Version 2.0\n\n## Contribution\n\nLaunch database for testing:\n\n```\n$ docker compose up --build\n```\n\nRun acceptance test:\n\n```\n$ docker compose -f docker-compose-test.yml up --build\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffuture-architect%2Fgo-twowaysql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffuture-architect%2Fgo-twowaysql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffuture-architect%2Fgo-twowaysql/lists"}