1
- > 🚨
2
- >
3
- > sqlc is ** new** and under rapid development.
4
- >
5
- > The code it generates is correct and safe for production use, but there is
6
- > currently no guarantee of stability or backwards-compatibility of the command
7
- > line interface, configuration file format or generated code.
8
- >
9
- > 🚨
10
-
11
1
# sqlc: A SQL Compiler
12
2
13
3
> And lo, the Great One looked down upon the people and proclaimed:
@@ -232,6 +222,7 @@ Your favorite PostgreSQL / Go features are supported:
232
222
- [ Query annotations] ( ./docs/annotations.md )
233
223
- [ Transactions] ( ./docs/transactions.md )
234
224
- [ Prepared queries] ( ./docs/prepared_query.md )
225
+ - [ Named parameters] ( ./docs/named_parameters.md )
235
226
- [ SELECT] ( ./docs/query_one.md )
236
227
- [ NULL] ( ./docs/null.md )
237
228
- [ COUNT] ( ./docs/query_count.md )
@@ -265,7 +256,7 @@ Available Commands:
265
256
compile Statically check SQL for syntax and type errors
266
257
generate Generate Go code from SQL
267
258
help Help about any command
268
- init Create an empty sqlc.json settings file
259
+ init Create an empty sqlc.yaml settings file
269
260
version Print the sqlc version number
270
261
271
262
Flags:
@@ -276,24 +267,19 @@ Use "sqlc [command] --help" for more information about a command.
276
267
277
268
## Settings
278
269
279
- The ` sqlc ` tool is configured via a ` sqlc.json ` file. This file must be
270
+ The ` sqlc ` tool is configured via a ` sqlc.yaml ` file. This file must be
280
271
in the directory where the ` sqlc ` command is run.
281
272
282
- ``` json
283
- {
284
- "version" : " 1" ,
285
- "packages" : [
286
- {
287
- "name" : " db" ,
288
- "emit_json_tags" : true ,
289
- "emit_prepared_queries" : false ,
290
- "emit_interface" : true ,
291
- "path" : " internal/db" ,
292
- "queries" : " ./sql/query/" ,
293
- "schema" : " ./sql/schema/"
294
- }
295
- ]
296
- }
273
+ ``` yaml
274
+ version : " 1"
275
+ packages :
276
+ - name : " db" ,
277
+ emit_json_tags : true
278
+ emit_prepared_queries : false
279
+ emit_interface : true
280
+ path : " internal/db"
281
+ queries : " ./sql/query/"
282
+ schema : " ./sql/schema/"
297
283
` ` `
298
284
299
285
Each package document has the following keys:
@@ -324,17 +310,12 @@ If a different Go package for UUIDs is required, specify the package in the
324
310
` overrides` array. In this case, I'm going to use the `github.com/gofrs/uuid`
325
311
instead.
326
312
327
- ```
328
- {
329
- "version": "1",
330
- "packages": [...],
331
- "overrides": [
332
- {
333
- "go_type": "github.com/gofrs/uuid.UUID",
334
- "db_type": "uuid"
335
- }
336
- ]
337
- }
313
+ ` ` ` yaml
314
+ version: "1"
315
+ packages: [...]
316
+ overrides:
317
+ - go_type: "github.com/gofrs/uuid.UUID"
318
+ db_type: "uuid"
338
319
` ` `
339
320
340
321
Each override document has the following keys :
@@ -354,36 +335,24 @@ This may be configured by specifying the `column` property in the override defin
354
335
should be of the form `table.column` buy you may be even more specify by specifying `schema.table.column`
355
336
or `catalog.schema.table.column`.
356
337
357
- ```
358
- {
359
- "version": "1",
360
- "packages": [...],
361
- "overrides": [
362
- {
363
- "column": "authors.id",
364
- "go_type": "github.com/segmentio/ksuid.KSUID"
365
- }
366
- ]
367
- }
338
+ ` ` ` yaml
339
+ version: "1"
340
+ packages: [...]
341
+ overrides:
342
+ - column: "authors.id"
343
+ go_type: "github.com/segmentio/ksuid.KSUID"
368
344
` ` `
369
345
370
346
# ## Package Level Overrides
371
347
372
348
Overrides can be configured globally, as demonstrated in the previous sections, or they can be configured on a per-package which
373
349
scopes the override behavior to just a single package :
374
350
351
+ ` ` ` yaml
352
+ version: "1"
353
+ packages:
354
+ - overrides: [...]
375
355
` ` `
376
- {
377
- "version": "1",
378
- "packages": [
379
- {
380
- ...
381
- "overrides": [...]
382
- }
383
- ],
384
- }
385
- ```
386
-
387
356
388
357
# ## Renaming Struct Fields
389
358
@@ -401,14 +370,11 @@ If you're not happy with a field's generated name, use the `rename` dictionary
401
370
to pick a new name. The keys are column names and the values are the struct
402
371
field name to use.
403
372
404
- ``` json
405
- {
406
- "version" : " 1" ,
407
- "packages" : [... ],
408
- "rename" : {
409
- "spotify_url" : " SpotifyURL"
410
- }
411
- }
373
+ ```yaml
374
+ version: "1"
375
+ packages: [...]
376
+ rename:
377
+ spotify_url: "SpotifyURL"
412
378
```
413
379
414
380
## Downloads
@@ -420,7 +386,8 @@ Each commit is deployed to the [`devel` channel on Equinox](https://dl.equinox.i
420
386
## Other Databases and Languages
421
387
422
388
sqlc currently only supports PostgreSQL / Go. MySQL support has been merged,
423
- but it's marked as experimental. SQLite and TypeScript support are planned.
389
+ but it's marked as experimental. SQLite, TypeScript, and Kotlin support are
390
+ planned.
424
391
425
392
| Language | PostgreSQL | MySQL | SQLite |
426
393
| ------------ | :----------------:| :----------------:| :----------------:|
@@ -429,6 +396,21 @@ but it's marked as experimental. SQLite and TypeScript support are planned.
429
396
430
397
If you'd like to add another database or language, we'd welcome a contribution.
431
398
399
+ ## Sponsors
400
+
401
+ sqlc development is funded by our generous sponsors.
402
+
403
+ - Companies
404
+ - [ Meter] ( https://meter.com )
405
+ - [ ngrok] ( https://ngrok.com )
406
+ - Individuals
407
+ - [ CyberAx] ( https://github.com/Cyberax )
408
+
409
+ If you use sqlc at your company, please consider [ becoming a
410
+ sponsor] ( https://github.com/sponsors/kyleconroy ) today.
411
+
412
+ Sponsors receive priority support via the sqlc Slack organization.
413
+
432
414
## Acknowledgements
433
415
434
416
sqlc was inspired by [ PugSQL] ( https://pugsql.org/ ) and
0 commit comments