https://github.com/kaashyapan/sqlc-gen-crud
Sqlc plugin to autogenerate CRUD Sql from schema file
https://github.com/kaashyapan/sqlc-gen-crud
code-generator codegen fsharp go kotlin mysql orm postgresql python sqlc sqlite
Last synced: about 2 months ago
JSON representation
Sqlc plugin to autogenerate CRUD Sql from schema file
- Host: GitHub
- URL: https://github.com/kaashyapan/sqlc-gen-crud
- Owner: kaashyapan
- License: mit
- Created: 2023-05-28T16:52:37.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2023-06-22T15:04:51.000Z (almost 2 years ago)
- Last Synced: 2025-02-01T23:41:14.064Z (3 months ago)
- Topics: code-generator, codegen, fsharp, go, kotlin, mysql, orm, postgresql, python, sqlc, sqlite
- Language: Go
- Homepage:
- Size: 54.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Sqlc plugin for generating crud SQL
`sqlc` is a command line program that generates type-safe database access code from SQL.\
Sqlc documentation - https://sqlc.devThis plugin reads a schema file and generates basic CRUD Sql statements for all the tables.\
It can be run before any language specific codegen steps to bootstrap a project.```json
{
"version": "2",
"plugins": [
{
"name": "gen-crud",
"wasm": {
"url": "https://github.com/kaashyapan/sqlc-gen-crud/releases/download/v1.0.1/sqlc-gen-crud_1.0.1.wasm",
"sha256": "1a8146b30585882a8104d2ddcbfef0438b953fff08e74e7b90a9bf3d7bb2764c"
}
}
],
"sql": [
{
"engine": "postgresql",
"schema": "schema.sql",
"queries": "dummy.sql",
"codegen": [
{
"out": <..target_folder...>,
"plugin": "gen-crud",
"options": {
}
}
]
}
]
}
```
- ```sqlc generate```## How to use
- Put your schema in schema.sql
- `sqlc` doesnt let you run without an sql file. So make a dummy.sql file as below
```sql
-- dummy :one
select current_timestamp;
```
- Make a config file `crud.json` as shown above
Run `sqlc -f crud.json generate`- Produces 6 Sql statements select, insert, update, delete, list & count.
See the example folder for a sample setup.