Postgres drop database error: pq: cannot drop the currently open database
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to drop the database I'm currently connected to like so, but I'm getting this error: pq: cannot drop the currently open database I don't really understand how I'm expected to drop the database if I have to close my connection, because then I don't think I will be able to use dbConn.Exec to execute my DROP DATABASE statement? dbConn *sql.DB func stuff() error { _, err := dbConn.Exec(fmt.Sprintf(`DROP DATABASE %s;`, dbName)) if err != nil { return err } return dbConn.Close() } I guess I could connect to a different database and then