Skip to content

Commit

Permalink
docs: Move the sqlc Dashboard section lower in getting started (#3110)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyleconroy committed Jan 5, 2024
1 parent 023ab78 commit f0ef223
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 20 deletions.
42 changes: 42 additions & 0 deletions docs/tutorials/getting-started-mysql.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ We'll generate Go code here, but other
naturally need the Go toolchain if you want to build and run a program with the
code sqlc generates, but sqlc itself has no dependencies.

At the end, you'll push your SQL queries to [sqlc Cloud](https://dashboard.sqlc.dev/) for further insights and analysis.

## Setting up

Create a new directory called `sqlc-tutorial` and open it up.
Expand Down Expand Up @@ -181,3 +183,43 @@ database must have the `authors` table as defined in `schema.sql`.

You should now have a working program using sqlc's generated Go source code,
and hopefully can see how you'd use sqlc in your own real-world applications.

## Query analysis and managed databases

[sqlc Cloud](https://dashboard.sqlc.dev) provides additional insights into your
queries, catching subtle bugs and performance issues. To get started, create a
[dashboard account](https://dashboard.sqlc.dev). Once you've signed in, create a
project and generate an auth token. Add your project's ID to the `cloud` block
to your sqlc.yaml.

```yaml
version: "2"
cloud:
# Replace <PROJECT_ID> with your project ID from the sqlc Cloud dashboard
project: "<PROJECT_ID>"
sql:
- engine: "mysql"
queries: "query.sql"
schema: "schema.sql"
gen:
go:
package: "tutorial"
out: "tutorial"
```

Replace `<PROJECT_ID>` with your project ID from the sqlc Cloud dashboard. It
will look something like `01HA8SZH31HKYE9RR3N3N3TSJM`.

And finally, set the `SQLC_AUTH_TOKEN` environment variable:

```shell
export SQLC_AUTH_TOKEN="<your sqlc auth token>"
```

```shell
$ sqlc push --tag tutorial
```

In the sidebar, go to the "Insights" section to run checks against your queries.
If you need access to a pre-configured MySQL database, check out [managed
databases](../howtwo/managed-databases.md).
63 changes: 43 additions & 20 deletions docs/tutorials/getting-started-postgresql.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@ We'll generate Go code here, but other
naturally need the Go toolchain if you want to build and run a program with the
code sqlc generates, but sqlc itself has no dependencies.

We'll also rely on sqlc's [managed databases](../howto/managed-databases.md),
which require a sqlc Cloud project and auth token. You can get those from
the [sqlc Cloud dashboard](https://dashboard.sqlc.dev/). Managed databases are
an optional feature that improves sqlc's query analysis in many cases, but you
can turn it off simply by removing the `cloud` and `database` sections of your
configuration.
At the end, you'll push your SQL queries to [sqlc
Cloud](https://dashboard.sqlc.dev/) for further insights and analysis.

## Setting up

Expand All @@ -31,31 +27,17 @@ following contents:

```yaml
version: "2"
cloud:
# Replace <PROJECT_ID> with your project ID from the sqlc Cloud dashboard
project: "<PROJECT_ID>"
sql:
- engine: "postgresql"
queries: "query.sql"
schema: "schema.sql"
database:
managed: true
gen:
go:
package: "tutorial"
out: "tutorial"
sql_package: "pgx/v5"
```

Replace `<PROJECT_ID>` with your project ID from the sqlc Cloud dashboard. It
will look something like `01HA8SZH31HKYE9RR3N3N3TSJM`.

And finally, set the `SQLC_AUTH_TOKEN` environment variable:

```shell
export SQLC_AUTH_TOKEN="<your sqlc auth token>"
```

## Schema and queries

sqlc needs to know your database schema and queries in order to generate code.
Expand Down Expand Up @@ -220,3 +202,44 @@ database must have the `authors` table as defined in `schema.sql`.

You should now have a working program using sqlc's generated Go source code,
and hopefully can see how you'd use sqlc in your own real-world applications.

## Query analysis and managed databases

[sqlc Cloud](https://dashboard.sqlc.dev) provides additional insights into your
queries, catching subtle bugs and performance issues. To get started, create a
[dashboard account](https://dashboard.sqlc.dev). Once you've signed in, create a
project and generate an auth token. Add your project's ID to the `cloud` block
to your sqlc.yaml.

```yaml
version: "2"
cloud:
# Replace <PROJECT_ID> with your project ID from the sqlc Cloud dashboard
project: "<PROJECT_ID>"
sql:
- engine: "postgresql"
queries: "query.sql"
schema: "schema.sql"
gen:
go:
package: "tutorial"
out: "tutorial"
sql_package: "pgx/v5"
```

Replace `<PROJECT_ID>` with your project ID from the sqlc Cloud dashboard. It
will look something like `01HA8SZH31HKYE9RR3N3N3TSJM`.

And finally, set the `SQLC_AUTH_TOKEN` environment variable:

```shell
export SQLC_AUTH_TOKEN="<your sqlc auth token>"
```

```shell
$ sqlc push --tag tutorial
```

In the sidebar, go to the "Insights" section to run checks against your queries.
If you need access to a pre-configured PostgreSQL database, check out [managed
databases](../howtwo/managed-databases.md).

0 comments on commit f0ef223

Please sign in to comment.