A lightweight, concurrent microservice API built in Go for executing SQL queries against multiple ODBC drivers.
-
Golang 1.20+
-
.env
file with database credentialsDuplicate
.env.example
to.env
and fill in the values. -
IBM DB2 CLI Driver installed
Wait for Docker Compose instructions.
You need to set GOOS
and GOARCH
:
GOOS=windows GOARCH=amd64 go build -o app.exe main.go
⚠️ The IBM DB2 driver must be available in the build machine. For Windows, you may need to compile inside a Windows VM or Docker container with the proper environment.
./app.exe
The server will start on port 40500
and expose one endpoint.
This application can (and should) be installed as a system service for production use.
-
Download NSSM and add it to PATH
-
Run:
nssm install ODBC_API_Service "C:\go-odbc-middleware\app.exe"
-
Start the service:
nssm start ODBC_API_Service
Make sure the port is free (e.g. 40500) and your environment variables are set correctly.
{
"query": "SELECT * FROM table_name",
"source": 1
}
query
: SQL string to executesource
: integer matching theDB_DSN_n
environment variable
{
"columns": ["id", "name", "email"],
"data": [
{"id": 1, "name": "Alice", "email": "alice@example.com"},
{"id": 2, "name": "Bob", "email": "bob@example.com"}
]
}
⚠️ This API executes raw SQL. Do not expose to untrusted users.
- Token-based auth (e.g. HMAC or JWT)
- Configurable query whitelisting
- Logging control and access auditing
- Rate limiting to prevent abuse
Feel free to contribute or open issues for feature requests.
This app is maintained by @bon4to.