go-gorm / postgres

GORM PostgreSQL driver
MIT License
234 stars 123 forks source link

Option to use a uri like „postgres://user:password@host:port/database“ #70

Closed dattito closed 2 years ago

dattito commented 3 years ago

Your Question

Simple Question, but hard to find an answer online: Is there an option to use URIs instead of DSNs to connect to the database? This would make working with Heroku Postgres a lot easier!

The document you expected this should be explained

Expected answer

jinzhu commented 2 years ago

Maybe create an issue on pgx driver?

ktarplee commented 2 years ago

URI's already work with this driver in GORM since the underlying postgres driver already supports it. I use URI all the time for gorm/postgres. The only part that might not work is in this code base (but I have not hit an issue with it). It is this line https://github.com/go-gorm/postgres/blob/6752fb0c81ab98d437cbb100026f72ea8444bd0f/postgres.go#L65

It would be nice if the documentation was updated to point out that URIs do in fact work.