Mango SQL is coming

Mango SQL is coming

Aug 17, 2024

Hi Everyone,
Time to present my last project Mango SQL, a CLI to statically generate a SQL client for your Go projects.


What is it ?
Doing more and more Golang for the past year, multiple time I had to deal with SQL and never get really satisfied with the state of SQL Clients in the Golang ecosystem.
There are more or less two different approach:
1. Use an ORM like GORM, but they are slow, have limited feature set and require to learn their syntax
2. Directly use low level drivers, great performance but clunky documentations, really verbose to write and weird quirks

And both approach get your tight to either a library or a technology (if you use gorm, you have to use gorm syntax. If you use pgx you are tight to postgres). This make code less portable and more annoying to handle, and if you change database you have to change part of your project.
So I decided to work on that a propose something different, a SQL code generator

How it works ?
Really simple, Mango SQL is a code generator for your Database, exactly like you may already have for Protobuf, GraphQL, Openapi, ...
1. It parse your schema or migrations files (in .sql) to understand your database structure
2. It then generate all the code you need to interact with your database (structs and functions to provide you CRUD behaviors, ...)
3. You can just use the generated client in your codebase

Why is it different ?
It's an hybrid approach which has lot of great properties:
1. Everything is generated at build time, give really great performances at runtime unlike ORM
2. Really fast iteration, modify your DB schema, run a cli command and your are up-to-date, unlike manually maintained code
3. Can easily be integrated with 3rd party database (imagine directly generating a client for wordpress, shopify, ...)

What's the plan ?
My goal is to keep Mango SQL open source, add more features I have in the back of my mind. Then stabilize it and make it production ready ^^

Enjoy this post?

Buy Kevin Destrem (@kefniark) a coffee