Sherloque is a language agnostic SQL SDK generator. Inspired by GraphqQL Code Generator
You will want Sherloque if: 1. You want to know if your SQL queries are correct without actually running it 2. You want the return type of your SQL queries 3. You don't want to use macros/template 4. You want to write pure SQL
You just need to provide 3 kind of files: 1. Database schema (CREATE TABLE ...) 2. SQL operations (SELECT/UPDATE/DELETE) 3. Sherloque configuration
CREATE TABLE pet (
id INT NOT NULL,
ownerid INT NOT NULL,
kind VARCHAR(255) NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY (ownerid) REFERENCES person(id)
);
2. Database Operation
(Note that variables are prefixed with `$`)
sql
-- The name of this file: getUserPetsCount.sql
SELECT person.name, count()
FROM person INNER JOIN pet
ON person.id = pet.owner_id
WHERE pet.kind = $petKind
GROUP BY person.id;
3. Sherloque config
json
{
"language": "typescript",
"schemas": "./schema//.sql",
"operations": "./src//.sql",
"output": "./sdk.ts",
"database": "mysql"
}
4. Result (generated SDK)
ts
export default class
"person.name": string,
"count(
|Library|SQL Verification|Pure SQL Support|Language Agnostic|Database Connection| |--|--|--|--|--| |Rust Diesel|✓|||✓| |SQLx|✓|✓||✓| |Sherloque|✓|✓|✓|