{"id":15294816,"url":"https://github.com/emanuel-skrenkovic/tql","last_synced_at":"2026-02-13T08:41:53.940Z","repository":{"id":176686544,"uuid":"637024835","full_name":"emanuel-skrenkovic/tql","owner":"emanuel-skrenkovic","description":"Generics around database/sql with an api for simple use-cases.","archived":false,"fork":false,"pushed_at":"2024-10-19T08:42:10.000Z","size":299,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-30T22:38:29.153Z","etag":null,"topics":["generics","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/emanuel-skrenkovic.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":"2023-05-06T09:17:37.000Z","updated_at":"2024-10-19T08:42:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"300d7927-c8bc-4f09-b9ad-12b5c0140dd3","html_url":"https://github.com/emanuel-skrenkovic/tql","commit_stats":{"total_commits":35,"total_committers":2,"mean_commits":17.5,"dds":"0.11428571428571432","last_synced_commit":"d6bb7baf525fc0e470fd23e9a5048dc5ade745a4"},"previous_names":["eskrenkovic/typeql","eskrenkovic/tql","emanuel-skrenkovic/tql"],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emanuel-skrenkovic%2Ftql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emanuel-skrenkovic%2Ftql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emanuel-skrenkovic%2Ftql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emanuel-skrenkovic%2Ftql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/emanuel-skrenkovic","download_url":"https://codeload.github.com/emanuel-skrenkovic/tql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227687586,"owners_count":17804394,"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":["generics","go","golang","sql"],"created_at":"2024-09-30T17:07:09.568Z","updated_at":"2026-02-13T08:41:48.899Z","avatar_url":"https://github.com/emanuel-skrenkovic.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tql\n\nSimple convenience functions (with generics) around `database/sql`.\nDesigned to be used with existing `sql.DB`, `sql.Tx` types.\n\nMarshals rows into structs using the `db` tag. For the struct field to be marshalled, it needs to contain the `db` tag.\n\n### Example usage:\n```go\ntype Foo struct {\n    ID    string `db:\"id\"`\n    Value string `db:\"value\"`\n}\n\nconst query = \"SELECT * FROM foo WHERE value = $1;\"\n\nfoos, err := tql.Query[Foo](context.Background(), db, query, \"bar\")\nif err != nil { \n    // error handling\n}\n\n// do stuff with foos \n```\n\n### Supports named parameters:\n```go\ntype Foo struct {\n    ID    string `db:\"id\"`\n    Value string `db:\"value\"`\n}\n\nfoo := Foo {\n    ID:    \"foo\",\n    Value: \"bar\",\n}\n\nconst stmt = \"INSERT INTO foo (id, value) VALUES (:id, :value);\"\n\nresult, err := tql.Exec(context.Background(), db, stmt, foo)\nif err != nil { \n    // error handling\n}\n\n// do stuff with result\n```\n\n## API\n```go\nQuerySingle[T any](ctx context.Context, q Querier, query string, params ...any) (T, error)\n\nQuerySingleOrDefault[T any](ctx context.Context, q Querier, def T, query string, params ...any) (T, error)\n\nQueryFirst[T any](ctx context.Context, q Querier, query string, params ...any) (T, error)\n\nQueryFirstOrDefault[T any](ctx context.Context, q Querier, def T, query string, params ...any) (T, error)\n\nQuery[T any](ctx context.Context, q Querier, query string, params ...any) ([]T, error)\n\nExec(ctx context.Context, e Executor, query string, params ...any) (sql.Result, error) \n```\n\n## Interfaces used\n```go\ntype Executor interface {\n    ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)\n}\n\ntype Querier interface {\n    QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)\n    QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femanuel-skrenkovic%2Ftql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femanuel-skrenkovic%2Ftql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femanuel-skrenkovic%2Ftql/lists"}