cockroachdb / cockroachdb/docs
sqlalchemy example should just use cockroachdb and not postgresql in the connection string
- 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://`

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.