A Go library that helps you keep SQL files separate from code and execute them with named queries.
dotsql is a Go library that enables developers to store SQL queries in external files and execute them using named identifiers. It solves the problem of cluttering Go code with raw SQL strings by providing a clean separation between SQL logic and application code. The library supports dynamic query generation through templating and integrates seamlessly with Go's standard database interfaces.
Go developers working with SQL databases who prefer to keep SQL queries in separate files for better organization and maintainability.
Developers choose dotsql for its simplicity and focus on SQL file management without the overhead of an ORM. It offers a lightweight alternative to embedding SQL in code, with features like named queries and template support for dynamic SQL.
A Golang library for using SQL.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Stores SQL in external files, keeping queries separate from Go code, which improves maintainability and adheres to separation of concerns, as highlighted in the philosophy section.
Uses unique identifiers like --name:create-user to load and execute queries easily, reducing clutter and errors from embedded SQL strings.
Supports Go's text/template for dynamic SQL generation via .WithData(), allowing conditional logic and data interpolation in queries.
Works directly with Go's database/sql package, supporting standard methods like Exec, Query, and Prepare without extra abstraction layers.
Requires managing separate SQL files, and embedding them into binaries needs additional tools like gotic, adding complexity to distribution and setup.
Uses text/template which, if not carefully sanitized, can introduce SQL injection vulnerabilities, especially with dynamic user inputs in templates.
Lacks built-in support for transactions, migrations, or connection pooling, forcing developers to implement these manually or use other libraries.