cockroachdb / cockroachdb/docs
sqlalchemy example should just use cockroachdb and not postgresql in the connection string
- 主要言語
- HTML
- スター
- 212
- フォーク
- 476
- 平均マージ
- 40分
- マージ済み PR(30日)
- 3
説明
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
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
評価
この issue はまだ評価されていません。