Crates.io | sherloque |
lib.rs | sherloque |
version | 0.0.1 |
source | src |
created_at | 2021-06-12 07:10:20.627218 |
updated_at | 2021-06-12 07:10:20.627218 |
description | A language agnostic SQL SDK generator. |
homepage | |
repository | |
max_upload_size | |
id | 409241 |
size | 8,491 |
Sherloque is a language agnostic SQL SDK generator. Inspired by GraphqQL Code Generator
You will want Sherloque if:
You just need to provide 3 kind of files:
CREATE TABLE person (
id INT NOT NULL,
name VARCHAR(255) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE pet (
id INT NOT NULL,
owner_id INT NOT NULL,
kind VARCHAR(255) NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY (owner_id) REFERENCES person(id)
);
$
)-- 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;
{
"language": "typescript",
"schemas": "./schema/**/*.sql",
"operations": "./src/**/*.sql",
"output": "./sdk.ts",
"database": "mysql"
}
export default class<T extends Database> {
constructor(private db: T) {}
getUserPetsCount(args: {petKind: string}): Promise<{
"person.name": string,
"count(*)": number
}[]> {
// generated code
}
}
Library | SQL Verification | Pure SQL Support | Language Agnostic | Database Connection |
---|---|---|---|---|
Rust Diesel | ✓ | ✓ | ||
SQLx | ✓ | ✓ | ✓ | |
Sherloque | ✓ | ✓ | ✓ |
It does not support SQL connection, it merely provide SDKs with properly typed functions that generate SQL queries.