Skip to content

Commit 06d2b4b

Browse files
Improve README (#38)
* Improve README * Update README.md * small fix --------- Co-authored-by: Ilan Uzan <[email protected]>
1 parent f29ffdd commit 06d2b4b

File tree

3 files changed

+67
-43
lines changed

3 files changed

+67
-43
lines changed

README.md

+57-33
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,62 @@
11
# sqlc-gen-csharp
2+
## Usage
3+
### Configuration
4+
```yaml
5+
version: "2"
6+
plugins:
7+
- name: csharp
8+
wasm:
9+
url: https://github.com/DionyOSS/sqlc-gen-csharp/releases/download/v0.10.0/sqlc-gen-csharp_0.10.0.wasm
10+
sha256: 613ae249a541ab95c97b362bd1b0b572970edcad5eb2a11806a52d3f95e0f65f
11+
sql:
12+
# PostgreSQL Example
13+
- schema: "examples/authors/postgresql/schema.sql"
14+
queries: "examples/authors/postgresql/query.sql"
15+
engine: "postgresql"
16+
codegen:
17+
- plugin: csharp
18+
out: NpgsqlExample
19+
options:
20+
driver: Npgsql
21+
targetFramework: net8.0
22+
generateCsproj: true
23+
filePerQuery: false
24+
# MySQL Example
25+
- schema: "examples/authors/mysql/schema.sql"
26+
queries: "examples/authors/mysql/query.sql"
27+
engine: "mysql"
28+
codegen:
29+
- plugin: csharp
30+
out: MySqlConnectorExample
31+
options:
32+
driver: MySqlConnector
33+
```
34+
### Options Documentation
35+
| Option | Possible values | Info |
36+
|------------|---------------------------|-|
37+
| targetFramework | default: `net8.0`<br/>vaults: `netstandard2.0`, `netstandard2.1`, `net8.0` |Decide on the right target framework for your generated code, meaning the generated code will be compiled to the specified runtime.<br/>For more information and help deciding on the right value, refer to the [Microsoft .NET Standard documentation](https://learn.microsoft.com/en-us/dotnet/standard/net-standard?tabs=net-standard-1-0). |
38+
| generateCsproj | default: `true`<br/>values: `false`,`true` | This option is designed to assist you with the integration of SQLC and csharp by generating a `.csproj` file. This converts the generated output to a dynamic link library (DLL), simply a project that you can easily incorporate into your build process. |
39+
| filePerQuery | default: `false`<br/>values: `false`,`true` | This option allows users control on which `.cs` files to generate, when false it's one file per `.sql` SQLC query file, and when true it's one file per query. |
40+
41+
42+
## Supported SQL Engines
43+
- MySQL via [MySqlConnector](https://www.nuget.org/packages/MySqlConnector) package - [MySqlConnectorDriver](MySqlConnectorDriver/MySqlConnectorDriver.csproj)
44+
- PostgreSQL via [Npgsql](https://www.nuget.org/packages/Npgsql) package - [NpgsqlDriver](NpgsqlDriver/NpgsqlDriver.csproj)
45+
46+
47+
## Examples & Tests
48+
The below examples in here are automatically tested:
49+
- [MySqlConnectorExample](MySqlConnectorExample/MySqlConnectorExample.csproj)
50+
- [NpgsqlExample](NpgsqlExample/NpgsqlExample.csproj)
251

52+
53+
54+
<br/>
55+
<br/>
56+
<br/>
57+
58+
59+
# Local plugin development
360
## Prerequisites
461
make sure that the following applications are installed and exposed in your path
562

@@ -28,36 +85,3 @@ Testing the SQLC generated code via a predefined flow:
2885
make test-process-plugin
2986
make test-wasm-plugin
3087
```
31-
32-
## Supported SQL Engines
33-
- MySQL via [MySqlConnector](https://www.nuget.org/packages/MySqlConnector) package - [MySqlConnectorDriver](MySqlConnectorDriver/MySqlConnectorDriver.csproj)
34-
- PostgreSQL via [Npgsql](https://www.nuget.org/packages/Npgsql) package - [NpgsqlDriver](NpgsqlDriver/NpgsqlDriver.csproj)
35-
36-
## Configuration
37-
Options available for plugin:
38-
```yaml
39-
version: "2"
40-
plugins:
41-
- name: csharp
42-
env:
43-
- DEBUG
44-
process:
45-
cmd: ./dist/SqlcGenCsharpProcess
46-
sql:
47-
- schema: "examples/authors/postgresql/schema.sql"
48-
queries: "examples/authors/postgresql/query.sql"
49-
engine: "postgresql"
50-
codegen:
51-
- plugin: csharp
52-
out: NpgsqlExample
53-
options:
54-
driver: Npgsql
55-
minimalCsharp: 7.0
56-
filePerQuery: true
57-
generateCsproj: false
58-
```
59-
60-
## Examples & Tests
61-
The below examples in here are automatically tested:
62-
- [MySqlConnectorExample](MySqlConnectorExample/MySqlConnectorExample.csproj)
63-
- [NpgsqlExample](NpgsqlExample/NpgsqlExample.csproj)

sqlc.process.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ sql:
1313
options:
1414
driver: Npgsql
1515
# targetFramework: netstandard2.0
16-
# generateCsproj: false
17-
# filePerQuery: true
16+
# generateCsproj: true
17+
# filePerQuery: false
1818
- schema: "examples/authors/mysql/schema.sql"
1919
queries: "examples/authors/mysql/query.sql"
2020
engine: "mysql"
@@ -23,6 +23,6 @@ sql:
2323
out: MySqlConnectorExample
2424
options:
2525
driver: MySqlConnector
26-
# targetFramework: netstandard2.0
27-
# generateCsproj: false
28-
# filePerQuery: true
26+
# targetFramework: netstandard2.0,netsandard2.1,net8.0
27+
# generateCsproj: true
28+
# filePerQuery: false

sqlc.wasm.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ plugins:
33
- name: csharp
44
wasm:
55
url: file://dist/plugin.wasm
6-
sha256: b4d5451ff1cfa49157408215674ba65838c0f3566bb5bd19d14ac9ecc62ab065
6+
sha256: 613ae249a541ab95c97b362bd1b0b572970edcad5eb2a11806a52d3f95e0f65f
77
sql:
88
- schema: "examples/authors/postgresql/schema.sql"
99
queries: "examples/authors/postgresql/query.sql"
@@ -14,8 +14,8 @@ sql:
1414
options:
1515
driver: Npgsql
1616
# targetFramework: netstandard2.0
17-
# generateCsproj: false
18-
# filePerQuery: true
17+
# generateCsproj: true
18+
# filePerQuery: false
1919
- schema: "examples/authors/mysql/schema.sql"
2020
queries: "examples/authors/mysql/query.sql"
2121
engine: "mysql"
@@ -25,5 +25,5 @@ sql:
2525
options:
2626
driver: MySqlConnector
2727
# targetFramework: netstandard2.0
28-
# generateCsproj: false
29-
# filePerQuery: true
28+
# generateCsproj: true
29+
# filePerQuery: false

0 commit comments

Comments
 (0)