@@ -8,12 +8,8 @@ We'll generate Go code here, but other
88naturally need the Go toolchain if you want to build and run a program with the
99code sqlc generates, but sqlc itself has no dependencies.
1010
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.
1713
1814## Setting up
1915
@@ -31,31 +27,17 @@ following contents:
3127
3228``` yaml
3329version : " 2"
34- cloud :
35- # Replace <PROJECT_ID> with your project ID from the sqlc Cloud dashboard
36- project : " <PROJECT_ID>"
3730sql :
3831 - engine : " postgresql"
3932 queries : " query.sql"
4033 schema : " schema.sql"
41- database :
42- managed : true
4334 gen :
4435 go :
4536 package : " tutorial"
4637 out : " tutorial"
4738 sql_package : " pgx/v5"
4839` ` `
4940
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-
5941## Schema and queries
6042
6143sqlc 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`.
220202
221203You should now have a working program using sqlc's generated Go source code,
222204and 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