如何将iOS应用连接到Google Cloud SQL? [英] How do I connect an iOS app to Google Cloud SQL?

查看:89
本文介绍了如何将iOS应用连接到Google Cloud SQL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用Cloud Firestore构建数据库,因为这是最容易实现的.但是,Firestore的查询功能不足以满足我要构建的内容,这主要是因为它无法处理多个字段上的查询不平等.我需要一个SQL数据库.

I had been building my database using Cloud Firestore because this was the easiest to implement. However, the querying capabilities of Firestore are insufficient for what I want to build, mostly due to the fact it can't handle querying inequalities on multiple fields. I need a SQL database.

我已经设置了一个Google Cloud SQL实例.集成要比Firebase难得多,在Firebase中,您只需要添加一个Cocoapods Pod.从我的研究看来,我需要设置一个Cloud SQL代理,尽管如果有一种更简单的连接方法,我将很高兴听到它.

I have an instance of Google Cloud SQL set up. The integration is far harder than Firebase where you just need to add a Cocoapods Pod. From my research it looks like I need to set up a Cloud SQL proxy, although if there is a simpler way of connecting it, I'd be glad to hear about it.

本质上,我需要一种让iOS上的客户端读取和写入SQL数据库的方法. Cloud SQL似乎是最好,最具可扩展性的选项(尽管我乐于听取易于实施的替代方案).

Essentially, I need a way for a client on the iOS to read and write to a SQL database. Cloud SQL seemed like the best, most scalable option (though I'd be open to hearing about alternatives that are easy to implement).

推荐答案

您可能不想将应用程序配置为直接连接到SQL数据库. Firestore是一个高度可扩展的数据库,可以处理成千上万的连接-MySQL和Postgres的扩展规模不那么理想.

You probably don't want to configure your application to rely on connecting directly to an SQL database. Firestore is a highly scalable database that can handle thousands of connections - MySQL and Postgres do not scale as cleanly.

相反,您应该考虑构造一个简单的前端服务,该服务可用于查询数据库并返回格式化的结果.以这种方式进行构造有很多好处,包括能够进一步优化或分发查询. Google AppEngine Google Cloud Functions 都可以用来快速支持此类服务,并且都提供了到Cloud SQL的简单连接选项.

Instead, you should consider constructing a simple front end service that can be used to query the database and return formatted results. There are a variety of benefits to structuring this way, including being able to further optimize or distribute your queries. Google AppEngine and Google Cloud Functions can both be used to stand up such a service quickly, and both provide easy connection options to Cloud SQL.

这篇关于如何将iOS应用连接到Google Cloud SQL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆