简体   繁体   English

如何在 Google Sheet 和 Mysql DB 之间同步数据?

[英]How to sync data between a Google Sheet and a Mysql DB?

So I have a Google sheet that maintains a lot of data.所以我有一个保存大量数据的谷歌表。 I also have a MySQL DB with a huge junk of data.我还有一个带有大量垃圾数据的 MySQL 数据库。 There is a vital piece of information in the Sheet that is also present in the DB.工作表中有一条重要的信息也存在于数据库中。 Both needs to be in sync.两者需要同步。 The information always enters the Sheet first.信息总是首先进入工作表。 I had a python script with mysql queries to update my database separately.我有一个带有 mysql 查询的 python 脚本来分别更新我的数据库。

Now the work flow has changed.现在工作流程发生了变化。 Data will enter the sheet and whenever that happens the database has to updated automatically.数据将进入工作表,每当发生这种情况时,数据库必须自动更新。

  • After some research, I found that using the onEdit function of Google AppScript (I learned from here .), I could pickup when the file has changed.经过一番研究,我发现使用 Google AppScript 的onEdit功能(我从这里学习。),我可以在文件更改时进行拾取。
  • The Next step is to fetch the data from relevant cell, which I can do using this .下一步是从相关单元格中获取数据,我可以使用this来完成。
  • Now I need to connect to the DB and send some queries.现在我需要连接到数据库并发送一些查询。 This is where I am stuck.这就是我卡住的地方。

Approach 1:方法一:

Have a python web-app running live.让 python 网络应用程序实时运行。 Send the data via UrlFetchApp .This I yet have to try.通过UrlFetchApp发送数据。我还得试试。

Approach 2:方法二:

Connect to mySQL remotely through appscript.通过appscript远程连接mySQL。 But I am not sure this is possible after 2-3 hours of reading the docs.但我不确定这在阅读文档 2-3 小时后是否可行。

So this is my scenario.所以这是我的场景。 Any viable solution you can think of or a better approach?您能想到任何可行的解决方案或更好的方法吗?

Connect directly to mySQL.直接连接到 mySQL。 You likely missed reading this part https://developers.google.com/apps-script/guides/jdbc您可能错过了阅读这部分https://developers.google.com/apps-script/guides/jdbc

Using JDBC within Apps Script will work if you have the time to build this yourself.如果您有时间自己构建它,那么在 Apps 脚本中使用 JDBC就可以了。

If you don't want to roll your own solution, check out SeekWell .如果您不想推出自己的解决方案,请查看SeekWell It allows you to connect to databases and write SQL queries directly in Sheets.它允许您直接在表格中连接到数据库并编写 SQL 查询。 You can create a run a “Run Sheet” that will run multiple queries at once and schedule those queries to be run without you even opening the Sheet.您可以创建一个运行“运行表”,它会一次运行多个查询,并安排这些查询在您甚至不打开工作表的情况下运行。

Disclaimer : I made this.免责声明:我做了这个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Google Spreadsheet中同步计算机本地数据? - How to sync the computer local data in Google Spreadsheet? 如何将 pandas 中的数据上传到 Google 表格中? - How to upload data from pandas into Google sheet? 在prod和dev系统之间同步数据库 - sync db between prod and dev system 如何通过谷歌应用引擎从谷歌表格中读取数据? - How to read data from google sheet through google app engine? 如何将MySQL与python同步? - How to Sync MySQL with python? (Python / Django):如何让我的生产数据库同步(方案和数据)和dev pc db? - (Python/Django): How do I keep my production db in sync (scheme and data) and with dev pc db? 分布式系统中主从节点如何同步数据 - How to sync data between master and slave node in distributed systems Python:Google Spread Sheet API:如何设计在Google Sheet中存储用户数据? - Python: Google Spread Sheet API: How to design storing users data in Google Sheet? 如何在两个远程数据库之间同步MySQL数据库(无MySQL数据库复制技术) - How to sync a MySQL databases between two remote databases (without MySQL database replication technique ) 如何通过python正确更新Google Sheet图表数据范围? - How to properly update a Google Sheet chart data range via python?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM