{"id":13677246,"url":"https://github.com/georgysavva/scany","last_synced_at":"2025-04-23T20:53:25.074Z","repository":{"id":37414227,"uuid":"276623678","full_name":"georgysavva/scany","owner":"georgysavva","description":"Library for scanning data from a database into Go structs and more","archived":false,"fork":false,"pushed_at":"2025-03-19T19:59:58.000Z","size":271,"stargazers_count":1401,"open_issues_count":6,"forks_count":73,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-04-23T20:53:17.429Z","etag":null,"topics":["database","go","golang","mysql","pgx","postgresql","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/georgysavva.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":"2020-07-02T11:02:58.000Z","updated_at":"2025-04-23T04:09:31.000Z","dependencies_parsed_at":"2024-08-02T13:15:34.280Z","dependency_job_id":"090e9d5e-e053-40d7-ab36-5323d5b50466","html_url":"https://github.com/georgysavva/scany","commit_stats":{"total_commits":173,"total_committers":12,"mean_commits":"14.416666666666666","dds":0.09248554913294793,"last_synced_commit":"e49daf95ce4fc56bd09abf66ce4e6f2d827089c4"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/georgysavva%2Fscany","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/georgysavva%2Fscany/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/georgysavva%2Fscany/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/georgysavva%2Fscany/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/georgysavva","download_url":"https://codeload.github.com/georgysavva/scany/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250514767,"owners_count":21443208,"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":["database","go","golang","mysql","pgx","postgresql","sql"],"created_at":"2024-08-02T13:00:39.327Z","updated_at":"2025-04-23T20:53:25.052Z","avatar_url":"https://github.com/georgysavva.png","language":"Go","funding_links":[],"categories":["工具库","Utilities","SQL Builders","Go","公用事业公司","Repositories","工具库`可以提升效率的通用代码库和工具`","Utility"],"sub_categories":["查询语","Utility/Miscellaneous","实用程序/Miscellaneous","Fail injection","HTTP Clients"],"readme":"# scany\n\n[![Tests Status](https://github.com/georgysavva/scany/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/georgysavva/scany/actions/workflows/test.yml)\n[![Go Report Card](https://goreportcard.com/badge/github.com/georgysavva/scany)](https://goreportcard.com/report/github.com/georgysavva/scany)\n[![codecov](https://codecov.io/gh/georgysavva/scany/branch/master/graph/badge.svg)](https://codecov.io/gh/georgysavva/scany)\n[![PkgGoDev](https://pkg.go.dev/badge/github.com/georgysavva/scany/v2)](https://pkg.go.dev/github.com/georgysavva/scany/v2)\n[![Mentioned in Awesome Go](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go)\n\n## Overview\n\nGo favors simplicity, and it's pretty common to work with a database via driver directly without any ORM. It provides\ngreat control and efficiency in your queries, but here is a problem:\nyou need to manually iterate over database rows and scan data from all columns into a corresponding destination. It can\nbe error-prone verbose and just tedious. scany aims to solve this problem. It allows developers to scan complex data\nfrom a database into Go structs and other composite types with just one function call and don't bother with rows\niteration.\n\nscany isn't limited to any specific database. It integrates with `database/sql`, so any database with `database/sql`\ndriver is supported. It also works with [`pgx`](https://github.com/jackc/pgx) library native interface. Apart from the\nout-of-the-box support, scany can be easily extended to work with almost any database library.\n\nNote that scany isn't an ORM. First of all, it works only in one direction:\nit scans data into Go objects from the database, but it can't build database queries based on those objects. Secondly,\nit doesn't know anything about relations between objects e.g: one to many, many to many.\n\n## Features\n\n- Custom database column name via struct tag\n- Reusing structs via nesting or embedding\n- NULLs and custom types support\n- Omitted struct fields\n- Apart from structs, support for maps and Go primitive types as the destination\n- Override default settings\n\n## Install\n\n```\ngo get github.com/georgysavva/scany/v2\n```\n\n## How to use with `database/sql`\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"database/sql\"\n\n\t\"github.com/georgysavva/scany/v2/sqlscan\"\n)\n\ntype User struct {\n\tID    string\n\tName  string\n\tEmail string\n\tAge   int\n}\n\nfunc main() {\n\tctx := context.Background()\n\tdb, _ := sql.Open(\"postgres\", \"example-connection-url\")\n\n\tvar users []*User\n\tsqlscan.Select(ctx, db, \u0026users, `SELECT id, name, email, age FROM users`)\n\t// users variable now contains data from all rows.\n}\n```\n\nUse [`sqlscan`](https://pkg.go.dev/github.com/georgysavva/scany/v2/sqlscan)\npackage to work with `database/sql` standard library.\n\n## How to use with `pgx` native interface\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\n\t\"github.com/jackc/pgx/v5/pgxpool\"\n\n\t\"github.com/georgysavva/scany/v2/pgxscan\"\n)\n\ntype User struct {\n\tID    string\n\tName  string\n\tEmail string\n\tAge   int\n}\n\nfunc main() {\n\tctx := context.Background()\n\tdb, _ := pgxpool.New(ctx, \"example-connection-url\")\n\n\tvar users []*User\n\tpgxscan.Select(ctx, db, \u0026users, `SELECT id, name, email, age FROM users`)\n\t// users variable now contains data from all rows.\n}\n```\n\nUse [`pgxscan`](https://pkg.go.dev/github.com/georgysavva/scany/v2/pgxscan)\npackage to work with `pgx` library native interface.\n\n## How to use with other database libraries\n\nUse [`dbscan`](https://pkg.go.dev/github.com/georgysavva/scany/v2/dbscan) package that works with an abstract database,\nand can be integrated with any library that has a concept of rows. This particular package implements core scany\nfeatures and contains all the logic. Both `sqlscan` and `pgxscan` use `dbscan` internally.\n\n## Comparison with [`sqlx`](https://github.com/jmoiron/sqlx)\n\n- sqlx only works with `database/sql` standard library. scany isn't limited to `database/sql`. It also\n  supports [`pgx`](https://github.com/jackc/pgx) native interface and can be extended to work with any database library\n  independent of `database/sql`\n- In terms of scanning and mapping abilities, scany provides\n  all [features](https://github.com/georgysavva/scany#features) of sqlx\n- scany has a simpler API and much fewer concepts, so it's easier to start working with\n\n## Project documentation\n\nFor detailed project documentation see GitHub [Wiki](https://github.com/georgysavva/scany/wiki).\n\n## How to contribute\n\n- If you have an idea or a question, just post a pull request or an issue. Every feedback is appreciated.\n- If you want to help but don't know-how. All issues that you can work on are marked as `\"help wanted\"`. Discover all `\"help wanted\"` issues [here](https://github.com/georgysavva/scany/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22).\n\n## License\n\nThis project is licensed under the terms of the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeorgysavva%2Fscany","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeorgysavva%2Fscany","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeorgysavva%2Fscany/lists"}