cockroachdb / cockroachdb/docs

sqlalchemy example should just use cockroachdb and not postgresql in the connection string

Offen
#15,992 2 Kommentare 0 Reaktionen 1 zugewiesene Person Beansprucht von @ianjevans Auf GitHub ansehen
C-doc-improvement
Vorherrschende Sprache
HTML
Sterne
212
Forks
476
Ø Merge
40 Min.
Gemergte PRs (30 T.)
3

Beschreibung

Dikshant Adhikari (dikshant) commented:

I was a little confused by this example in our sqlalchemy docs and saw [someone in the community](https://cockroachdb.slack.com/archives/CP4D9LD5F/p1673446709408379] getting indirectly confused due to this.
```python3
if __name__ == '__main__':
# For cockroach demo:
# DATABASE_URL=postgresql://demo:@127.0.0.1:26257?sslmode=require
# For CockroachCloud:
# DATABASE_URL=postgresql://:@:26257/.defaultdb?sslmode=verify-full&sslrootcert=/
db_uri = os.environ['DATABASE_URL'].replace("postgresql://", "cockroachdb://")
try:
```
I don’t see a good reason to do this string substitution here. We should just have:
```python3
if __name__ == '__main__':
# For cockroach demo:
# DATABASE_URL=cockroachdb://demo:@127.0.0.1:26257?sslmode=require
# For CockroachCloud:
# DATABASE_URL=cockroachdb://:@:26257/.defaultdb?sslmode=verify-full&sslrootcert=/
db_uri = os.environ['DATABASE_URL')
try:
```
Because the UI already shows `cockroachdb://`
Screenshot 2023-01-12 at 2 09 15 PM

Also can we make it explicitly clear in a highlighted that when using SQLAlchemy the connection string should start with `cockroachdb` and not `postgres`.
See: https://github.com/cockroachdb/sqlalchemy-cockroachdb#install-and-usage

Jira Issue: DOC-6587

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.