A Go library for scanning database rows into structs, maps, and primitive types with minimal boilerplate.
Scany is a Go library that simplifies database interactions by scanning rows directly into Go structs, maps, and primitive types with a single function call. It eliminates the need for manual row iteration and column scanning, reducing boilerplate and potential errors while maintaining the simplicity and control of direct database access.
Go developers working directly with databases using the database/sql package or the pgx library who want to reduce repetitive scanning code without adopting a full ORM.
Developers choose Scany for its lightweight, non-intrusive approach that focuses solely on efficient data retrieval, offering database-agnostic support and a simpler API compared to alternatives like sqlx.
Library for scanning data from a database into Go structs and more
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Uses struct tags (e.g., `db:"column_name"`) to map database columns to field names, allowing schema changes without altering queries, as highlighted in the custom column mapping feature.
Works out-of-the-box with database/sql drivers and pgx native interface, and can be extended via the dbscan package, offering broad compatibility beyond standard libraries.
Reduces boilerplate with single function calls like Select() that handle row iteration and scanning, eliminating error-prone manual code, as shown in the examples.
Properly converts NULL database values to Go zero values or custom types, preventing runtime issues, which is a key feature mentioned in the README.
Scany only scans data into Go objects and cannot generate SQL queries based on structs, requiring developers to write all queries manually, which limits abstraction for complex operations.
Focuses solely on reading data from the database; inserts, updates, and deletes must be handled separately with other tools, offering no assistance for write operations.
Adds an external library dependency, and while lightweight, integrating with non-supported databases requires custom work using the dbscan package, increasing setup complexity.