New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't connect to posgres db #3539
Comments
The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 2 days if no further activity occurs. if you are asking question, please use the |
DBURL = fmt.Sprintf("host=%s port=%s user=%s password=%s dbname=%s sslmode=disable", host, port, user, password, dbname) |
The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 2 days if no further activity occurs. if you are asking question, please use the |
@lethienhoang You can comment out the DriverName line as you are going to use Gorm's postgres driver: db, err := gorm.Open(postgres.New(postgres.Config{
DSN: config.DBURL,
//DriverName: "postgres",
}), &gorm.Config{}) Another connection option: func Connect() *gorm.DB {
db, err := gorm.Open(postgres.Open(config.DBURL), &gorm.Config{})
if err != nil {
log.Fatal(err)
}
return db
} https://gorm.io/docs/connecting_to_the_database.html#PostgreSQL |
The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 2 days if no further activity occurs. if you are asking question, please use the |
same issue,why auto closed by bot? |
GORM Playground Link
go-gorm/playground#1
Description
`import (
"log"
"my-portfolio-api/config"
"my-portfolio-api/models"
)`
db, err := gorm.Open(postgres.New(postgres.Config{ DSN: config.DBURL, DriverName: config.DBDRIVER, }), &gorm.Config{})
I'm still getting the error "sql: unknown driver "postgres" (forgotten import?)". I'm getting error. How to fix it?
The text was updated successfully, but these errors were encountered: