Tech Stack Tales: Introducing StuctQL

January 14, 2020


StructQL is an open source Go package that allows for the complete management of SQL databases through native Go structs. You can check out the source code at and the docs at

For a closer look into the usage and advantages to StructQL, checkout Managing Your SQL Database in Go with StructQL


StructQL was initially built as a common library for standardizing and managing databases across microservices in the InFlow Count platform. Our objective was to build a package that would streamline database management for all developers. Our primary goals were to:

  • Protect from unsafe database use
  • Abstract SQL sanitation
  • Develop SQL Server agnostic code
  • Streamline data and table manipulations in Go

In InFlow Count, each microservice manages it's own SQL database. The microservices are solely responsible for the maintenance and accessibility of the information they maintain. Because of this we wanted to minimize the re-engineering conducted by developers for each microservice. With this in mind the the first two objectives are relatively self explanatory. We wanted abstract more advanced sanitation and unsafe usage from developers who may not be SQL experts. Next, we wholeheartedly believe in scalability and portability of code. That's why we wanted to build a framework that would allow us to change our SQL Server/Provider in the future without requiring significant redesign or changes. Finally, the standard Go SQL library has a number of redundant actions that make it very flexible but generally unwieldy. We decided that a system where the structs in the code tightly mimicked the SQL tables in the database would allow for more seamless data management improve readability and maintainability in our code. The tight coupling of structs to db tables follows the Go methodology of embedding documentation within the code. This meant that each of our microservice databases could be easily understood just through our Go structs.


StructQL closely resembles how JSON is handled in the standard Go library. It has been optimized for productivity and encourages best practices allowing developers to quickly create tables, conduct queries, and seamlessly manoeuvre through their SQL databases. An example of this is how StructQL requires the use of an ID column for each table even when this may not be entirely necessary. This, however, does not mean that the performance of StructQL queries will be any better than the standard SQL library. Ultimately the performance comes down the the developers individual implementation of their database and its use.


StructQL is very much in its infancy. Currently we support Postgres and intend to add MySQL functionality in the near future. Additionally, we are looking at constructing a more rigid query system that will avoid the use of SQL compliant WHERE conditions. We hope you find as much use out of StructQL as we do at InFlow, please feel free to report any issues as well as pull requests if you are interested in the project.

Jacoby Joukema
Jacoby is Co-Founder and Managing Director of InFlow. He is passionate about data driven decision making and commercializing cutting edge technologies.
Join Our Pilot Program
Sign-up for our InFlow Count Pilot Program today and Start Bringing People Back into the Equation.
LEarn More