scany
scany is a Go library that simplifies reading database query results into Go structs and other types without manual row iteration. It works with standard database/sql and the pgx driver, reducing boilerplate and error-prone code when working with databases directly.
Key facts
Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.
| Field | Value |
|---|---|
| Repository | georgysavva/scany |
| Owner | georgysavva |
| Primary language | Go |
| License | MIT — OSI-approved |
| Stars | 1.5k |
| Forks | 75 |
| Open issues | 3 |
| Latest release | v2.1.4 (2025-03-19) |
| Last updated | 2025-03-19 |
| Source | https://github.com/georgysavva/scany |
What scany is
scany provides struct scanning, NULL handling, nested/embedded type support, and custom column mapping via struct tags. It operates as a data-mapping layer above database/sql and pgx, not an ORM—handling only result deserialization, not query generation or relationships.
Get the scany source
Clone the repository and explore it locally.
git clone https://github.com/georgysavva/scany.gitcd scany# follow the project's README for install & configurationNeed it deployed, integrated, or customized instead? DEV.co ships production installs.
Best use cases
Implementation considerations
- Struct field names and column names must align or be mapped via struct tags; mismatches will cause silent skip or errors depending on configuration.
- NULL handling requires Pointer types or sql.NullType wrappers; ensure all nullable columns are properly typed to avoid scan failures.
- Custom types (e.g., JSON, UUID, arrays) need custom Scan/Value methods or post-processing; scany delegates to the database driver's type support.
- Query result order and column selection matter—scany maps by column name, not position, but performance depends on correct query design.
- Error handling is critical: invalid struct definitions, type mismatches, or connection failures will bubble up as scan errors; callers must check and log appropriately.
When to avoid it — and what to weigh
- Complex Entity Relationships Required — scany does not handle one-to-many, many-to-many, or other relational mapping. Projects needing automatic relationship loading should use a full ORM (e.g., GORM, ent).
- Query Building Abstraction Needed — scany only scans results; it cannot generate SQL from structs. If dynamic query building, migrations, or schema management are required, an ORM is more appropriate.
- Non-SQL Databases — scany is SQL-centric and integrates with database/sql or pgx. Projects using MongoDB, DynamoDB, or other NoSQL stores require alternative libraries.
- High-Level Abstraction Preference — Teams that prefer minimal SQL writing and maximum framework automation should evaluate full ORMs instead of a scanning-only library.
License & commercial use
Licensed under MIT (permissive OSI license). Allows commercial use, modification, and distribution with minimal restrictions; only requires retention of the license notice and copyright.
MIT license permits commercial use without royalties or restrictions. No commercial support or warranty is stated in the project. For production use, confirm internal legal review and consider whether a commercial support contract is needed.
DEV.co evaluation signals
Editorial assessment — not user reviews. Directional, with an explicit confidence level.
| Signal | Assessment |
|---|---|
| Maintenance | Active |
| Documentation | Adequate |
| License clarity | Clear |
| Deployment complexity | Low |
| DEV.co fit | Good |
| Assessment confidence | High |
scany itself is a mapping library with minimal attack surface. Security depends on the underlying database driver (database/sql or pgx) and query construction (always use parameterized queries to prevent SQL injection—scany does not generate queries). No known CVEs or security audit data provided.
Alternatives to consider
sqlx
More mature, database/sql-only alternative with similar scanning features. Wider adoption but less flexible for pgx users; different API design.
GORM
Full-featured ORM with query building, migrations, and relationship handling. Heavier, adds overhead, but solves more problems; overkill if only scanning is needed.
ent
Graph-based ORM with strong code generation and type safety. Opinionated schema-first approach; better for complex relationship modeling than scany.
Build on scany with DEV.co software developers
scany reduces boilerplate and errors in SQL result mapping. If your team prefers raw SQL with clean Go abstractions, evaluate scany for your next project or refactor.
Talk to DEV.coRelated on DEV.co
Explore the category and the services that help you build with it.
scany FAQ
Does scany generate SQL queries?
Can I use scany with databases other than PostgreSQL and MySQL?
What happens if a struct field doesn't match a column name?
Is scany suitable for high-concurrency applications?
Software development & web development with DEV.co
DEV.co helps companies turn open-source tools like scany into production software. Our software development services cover the full lifecycle — architecture, web development, integration, and maintenance — delivered by software developers and web developers who ship. Engage our software development agency to implement or customize it for your open-source databases stack.
Ready to streamline your Go database layer?
scany reduces boilerplate and errors in SQL result mapping. If your team prefers raw SQL with clean Go abstractions, evaluate scany for your next project or refactor.