cockroachdb / cockroachdb/docs
sqlalchemy example should just use cockroachdb and not postgresql in the connection string
- Dominant language
- HTML
- Stars
- 212
- Forks
- 476
- Avg merge
- 40m
- Merged PRs (30d)
- 3
Description
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
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.