You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+20-7Lines changed: 20 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,7 +27,14 @@ The plugin supports the following configuration options:
27
27
28
28
## Usage
29
29
30
-
### 1. Configure sqlc.yaml
30
+
### 1. Install the plugin
31
+
To use this plugin, you need to install it first. You can do this by running the following command:
32
+
33
+
```shell
34
+
go install github.com/tomtwinkle/sqlc-plugin-bulk-go@latest
35
+
```
36
+
37
+
### 2. Configure sqlc.yaml
31
38
32
39
Add the plugin to your sqlc configuration:
33
40
@@ -36,28 +43,34 @@ version: "2"
36
43
plugins:
37
44
- name: bulkinsert
38
45
process:
39
-
cmd: "go run github.com/tomtwinkle/sqlc-plugin-bulk-go"
40
-
options:
41
-
package: "db"# Replace with your database package name
42
-
46
+
cmd: "sqlc-plugin-bulk-go"
43
47
sql:
44
48
- schema: "path/to/schema.sql"
45
49
queries: "path/to/query.sql"
46
50
engine: "postgresql"# or "mysql"
47
51
codegen:
48
52
- plugin: bulkinsert
49
53
out: "path/to/output"
54
+
options:
55
+
package: "db"# Replace with your database package name
56
+
- schema: "path/to/schema.sql"
57
+
queries: "path/to/query.sql"
58
+
engine: "postgresql"# or "mysql"
59
+
gen:
60
+
go:
61
+
# sqlc-gen-go is the default codegen for sqlc
62
+
# https://github.com/sqlc-dev/sqlc-gen-go
50
63
```
51
64
52
-
### 2. Generate code
65
+
### 3. Generate code
53
66
54
67
Run sqlc to generate your code:
55
68
56
69
```bash
57
70
sqlc generate
58
71
```
59
72
60
-
### 3. Use the generated bulk insert functions
73
+
### 4. Use the generated bulk insert functions
61
74
62
75
For each INSERT query in your sqlc configuration, a corresponding bulk insert function will be generated. For example, if you have a query named `CreateUser`, a `BulkCreateUser` function will be generated.
0 commit comments