@@ -8,12 +8,8 @@ We'll generate Go code here, but other
8
8
naturally need the Go toolchain if you want to build and run a program with the
9
9
code sqlc generates, but sqlc itself has no dependencies.
10
10
11
- We'll also rely on sqlc's [ managed databases] ( ../howto/managed-databases.md ) ,
12
- which require a sqlc Cloud project and auth token. You can get those from
13
- the [ sqlc Cloud dashboard] ( https://dashboard.sqlc.dev/ ) . Managed databases are
14
- an optional feature that improves sqlc's query analysis in many cases, but you
15
- can turn it off simply by removing the ` cloud ` and ` database ` sections of your
16
- configuration.
11
+ At the end, you'll push your SQL queries to [ sqlc
12
+ Cloud] ( https://dashboard.sqlc.dev/ ) for further insights and analysis.
17
13
18
14
## Setting up
19
15
@@ -31,31 +27,17 @@ following contents:
31
27
32
28
``` yaml
33
29
version : " 2"
34
- cloud :
35
- # Replace <PROJECT_ID> with your project ID from the sqlc Cloud dashboard
36
- project : " <PROJECT_ID>"
37
30
sql :
38
31
- engine : " postgresql"
39
32
queries : " query.sql"
40
33
schema : " schema.sql"
41
- database :
42
- managed : true
43
34
gen :
44
35
go :
45
36
package : " tutorial"
46
37
out : " tutorial"
47
38
sql_package : " pgx/v5"
48
39
` ` `
49
40
50
- Replace ` <PROJECT_ID>` with your project ID from the sqlc Cloud dashboard. It
51
- will look something like `01HA8SZH31HKYE9RR3N3N3TSJM`.
52
-
53
- And finally, set the `SQLC_AUTH_TOKEN` environment variable :
54
-
55
- ` ` ` shell
56
- export SQLC_AUTH_TOKEN="<your sqlc auth token>"
57
- ` ` `
58
-
59
41
## Schema and queries
60
42
61
43
sqlc needs to know your database schema and queries in order to generate code.
@@ -220,3 +202,44 @@ database must have the `authors` table as defined in `schema.sql`.
220
202
221
203
You should now have a working program using sqlc's generated Go source code,
222
204
and hopefully can see how you'd use sqlc in your own real-world applications.
205
+
206
+ # # Query analysis and managed databases
207
+
208
+ [sqlc Cloud](https://dashboard.sqlc.dev) provides additional insights into your
209
+ queries, catching subtle bugs and performance issues. To get started, create a
210
+ [dashboard account](https://dashboard.sqlc.dev). Once you've signed in, create a
211
+ project and generate an auth token. Add your project's ID to the `cloud` block
212
+ to your sqlc.yaml.
213
+
214
+ ` ` ` yaml
215
+ version: "2"
216
+ cloud:
217
+ # Replace <PROJECT_ID> with your project ID from the sqlc Cloud dashboard
218
+ project: "<PROJECT_ID>"
219
+ sql:
220
+ - engine: "postgresql"
221
+ queries: "query.sql"
222
+ schema: "schema.sql"
223
+ gen:
224
+ go:
225
+ package: "tutorial"
226
+ out: "tutorial"
227
+ sql_package: "pgx/v5"
228
+ ` ` `
229
+
230
+ Replace `<PROJECT_ID>` with your project ID from the sqlc Cloud dashboard. It
231
+ will look something like `01HA8SZH31HKYE9RR3N3N3TSJM`.
232
+
233
+ And finally, set the `SQLC_AUTH_TOKEN` environment variable :
234
+
235
+ ` ` ` shell
236
+ export SQLC_AUTH_TOKEN="<your sqlc auth token>"
237
+ ` ` `
238
+
239
+ ` ` ` shell
240
+ $ sqlc push --tag tutorial
241
+ ` ` `
242
+
243
+ In the sidebar, go to the "Insights" section to run checks against your queries.
244
+ If you need access to a pre-configured PostgreSQL database, check out [managed
245
+ databases](../howtwo/managed-databases.md).
0 commit comments