我对 Web 开发以及 Google Cloud 中的更多内容还很陌生,对此感到抱歉。
基本上,我在 Swift 中做一个应用程序的后端部分(使用 Perfect),它在我的本地计算机上运行顺利并且没问题,我使用的是本地 Postgre 数据库(在我的应用程序中使用 PostgreORM)。
但是,当我将其部署到 Google Cloud 时,它无法识别数据库(我在计算机引擎中创建了一个相同的海报数据库和一个 Cloud SQL(具有相同名称和凭据的 Google Cloud 的 Postgre 服务),但又一次,当应用程序在云端时,它无法识别数据库,我缺少什么?我该怎么办?用Postgre安装其他docker镜像?
这是我的 DBConnector 代码:
import PostgresStORM
func setupDBCredentials() -> PostgresConnector.Type{
let connection = PostgresConnector.self
connection.host = "localhost" // or the connection name of the Google Cloud, it doesn't work as well
connection.username = "postgres"
connection.password = "nearby"
connection.database = "nearby"
connection.port = 5432
return connection
}
基本上,我如何让我的谷歌应用引擎代码连接到任何数据库?
此外,如果有帮助,我正在使用 Perfect Assistant 使用 Docker 将我的代码部署到 Google Cloud。
已经谢谢了!