我目前正在使用我的本地机器来操纵数据,谷歌应用引擎托管我的Web服务和Google Cloud SQL来处理数据库。 但是,我需要首先将数据上传到GAE,然后在GAE上运行后端作业,以便以后将所有数据上传到Google Cloud SQL。浪费两次上传数据是浪费的。 我想直接将某些日期从我的本地机器导入到Google Cloud SQL。

现在,Google Cloud SQL仅支持Google App Engine作为客户端。

Google Cloud SQL目前仅适用于Google App Engine 应用程序。要开发Google App Engine应用程序,您需要 安装App Engine SDK,可用于Python或Java: 但是,由于Google Cloud SQL以来提供了一个 jar db驱动程序允许命令从本地计算机执行线路客户端/ Squirrel SQL客户端访问。看起来我可以编写一些Java代码通过本地计算机中的此jar与云SQL交互。或者我可以使用像 jpype 访问Google Cloud SQL等工具。

是可能的吗?我应该在哪里开始? 或者是否有任何替代方法可以在本地计算机上使用Python访问Google Cloud SQL?

https://developers.google.com/cloud-sql/docs/commandline < / a>

http://jpype.sourceforge.net/

有帮助吗?

解决方案 2

I found a way to connect google cloud sql from python via SDK

def connect_sql(instance, database = None):
    from google.storage.speckle.python.tool import google_sql    
    database = google_sql.DatabaseConfig(instance, database)

    sql_cmd_config = google_sql.config.SQLCmdConfig(None)
    sql_cmd_config.add('__googlesql__', instance, None, None, database,
                    google_sql.GoogleSqlDriver.NAME, None, None)
    sql_cmd = google_sql.GoogleSqlCmd(sql_cmd_config)
    sql_cmd.set_database(instance)

    sql_cmd.preloop()
    return sql_cmd._SQLCmd__db

其他提示

This tool is new to me!

If this tool exists, why don't you use it to upload your data to Cloud SQL?

At the time of this writting, there's no official support to connect to Google Cloud SQL from the outside world. Google said is planning to allow access from anywhere in the near future.

In conclusion, try using this tool to upload your data. Using appengine as a middleware could be costly depending on the size of your data.

Cloud SQL now supports the native MySQL wire protocol [1], so you can use standard connectors such as Connector/Python [2]

  1. https://developers.google.com/cloud-sql/docs/external#wireprotocol
  2. http://dev.mysql.com/downloads/connector/python/
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top