Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connect: Fix and improve connection strings #151

Merged
merged 6 commits into from
Nov 22, 2024
106 changes: 81 additions & 25 deletions docs/connect/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,19 @@ In order to connect to CrateDB, your application or driver needs to be
configured with corresponding connection properties. Please note that different
applications and drivers may obtain connection properties in different formats.

<style>
/* Code blocks need to be slimmer */
.driver-slim div.highlight-default {
margin-top: 0.2em;
}
.driver-slim pre {
padding: 0.4em;
}
.driver-slim p {
margin-bottom: 0;
}
</style>

::::::{tab-set}

:::::{tab-item} CrateDB and CrateDB Cloud
Expand All @@ -38,34 +51,52 @@ applications and drivers may obtain connection properties in different formats.
:padding: 0

:::{grid-item}
:columns: 5
:columns: 4
:margin: 0
:padding: 0

**Connection properties**

:Host: `<clustername>`.cratedb.net
:Port: 5432 (PostgreSQL) or 4200 (HTTP)
:User: `<username>`
:Host: `<cluster>`.cratedb.net
:Port: 5432 (PostgreSQL) or<br>4200 (HTTP)
:User: `<user>`
:Pass: `<password>`

:::

:::{grid-item}
:columns: 7
:columns: 8
:margin: 0
:padding: 0
:class: driver-slim

**Connection-string examples**
<br><br>

A native PostgreSQL connection string.
`postgresql://<username>@<clustername>.cratedb.net/crate`
**Native PostgreSQL, psql**
```
postgresql://<user>:<password>@<cluster>.cratedb.net:5432/doc
```

A connection string for SQLAlchemy or Apache Flink.
`crate://<username>@<clustername>.cratedb.net/crate`
**JDBC: PostgreSQL pgJDBC**
```
jdbc:postgresql://<user>:<password>@<cluster>.cratedb.net:5432/doc
```

An HTTP URL to visit Admin UI.
`https://<username>@<clustername>.cratedb.net:4200/`
**JDBC: CrateDB JDBC, e.g. Apache Flink**
```
jdbc:crate://<user>:<password>@<cluster>.cratedb.net:5432/doc
```

**HTTP: Admin UI, CLI, CrateDB drivers**
```
https://<user>:<password>@<cluster>.cratedb.net:4200/
```

**SQLAlchemy**
```
crate://<user>:<password>@<cluster>.cratedb.net:4200/?schema=doc&ssl=true
```

:::

Expand All @@ -80,34 +111,52 @@ An HTTP URL to visit Admin UI.
:padding: 0

:::{grid-item}
:columns: 5
:columns: 4
:margin: 0
:padding: 0

**Connection properties**

:Host: localhost
:Port: 5432 (PostgreSQL) or 4200 (HTTP)
:Port: 5432 (PostgreSQL) or<br>4200 (HTTP)
:User: `crate`
:Pass: (empty)

:::

:::{grid-item}
:columns: 7
:columns: 8
:margin: 0
:padding: 0
:class: driver-slim

**Connection-string examples**
<br><br>

A native PostgreSQL connection string.
`postgresql://crate@localhost:5432/crate`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

technically /crate specifies the database to be used.
Unfortunately CrateDB still uses them in a non pg-compliant way
crate/crate#13502

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it is a good measure to slap the "Blocked by CrateDB" label onto the root issue, in order to increase awareness?

image

**Native PostgreSQL, psql**
```
postgresql://crate@localhost:5432/doc
```

**JDBC: PostgreSQL pgJDBC**
```
jdbc:crate://crate@localhost:5432/doc
```

**JDBC: CrateDB JDBC, e.g. Apache Flink**
```
jdbc:crate://<user>:<password>@localhost:5432/doc
```

A connection string for SQLAlchemy or Apache Flink.
`crate://crate@localhost/crate`
**HTTP: Admin UI, CLI, CrateDB drivers**
```
http://crate@localhost:4200/
```

An HTTP URL to visit Admin UI.
`http://crate@localhost:4200/`
**SQLAlchemy**
```
crate://crate@localhost:4200/?schema=doc
```

:::

Expand All @@ -118,11 +167,17 @@ An HTTP URL to visit Admin UI.


```{tip}
- Specify the [schema] name `doc`, if you are asked for a *database name*.
- The default [superuser] on a vanilla CrateDB cluster is called `crate`,
without a password.
- When aiming to authenticate properly, please learn about the available
[authentication] options.
- CrateDB's fixed catalog name is `crate`, the default schema name is `doc`.
- CrateDB does not implement the notion of a database,
however tables can be created in different [schemas].
- When asked for a *database name*, specifying a schema name (any),
or the fixed catalog name `crate` may be applicable.
- If a database-/schema-name is omitted while connecting,
the PostgreSQL drivers may default to the "username".
- The predefined [superuser] on an unconfigured CrateDB cluster is
called `crate`, defined without a password.
- For authenticating properly, please learn about the available
[authentication] options.
```
Comment on lines 169 to 181
Copy link
Member Author

@amotl amotl Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reply

Tools like DBeaver will default to your username as "database" name. In CrateDB this currently sets your searchpath to username. Do you want that?

This is certainly not intended, [...] improving the documentation [makes sense].

Thanks again. Within the "Tip" section below, I've added this item:

  • If a database-/schema-name is omitted while connecting,
    the PostgreSQL drivers may default to the "username".

Report

There have been a few more updates to this section, aiming to compress relevant details about those matters into a single spot.

image
-- Connect » Configure

Copy link
Member Author

@amotl amotl Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^^

Connect: Improve "Tip" section about specifics of catalog v db v schema

CrateDB is different in different aspects regarding the semantics of
common database servers, because it does not implement "databases".

This section aims to educate about the differences in a very concise
manner, including relevant hints that might save users from too many
permutations in probing failed connection attempts.

-- 8cd4341

We compiled those details based on a few empirical exercises, and your advises. Please validate.

Please let us know if you can think of anything missing in this summary, or if existing items need to improve in wording and overall clarity.

Copy link
Member Author

@amotl amotl Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it will not harm to merge this, now after refining it on behalf of multiple iterations. Please let me know about any improvements and wishes also in retrospective. Thanks for your valuable support so far!



Expand Down Expand Up @@ -513,4 +568,5 @@ ruby
[python-dbapi-by-example]: inv:crate-python:*:label#by-example
[python-sqlalchemy-by-example]: inv:sqlalchemy-cratedb:*:label#by-example
[schema]: inv:crate-reference:*:label#ddl-create-table-schemas
[schemas]: inv:crate-reference:*:label#ddl-create-table-schemas
[superuser]: inv:crate-reference:*:label#administration_user_management