[英]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.
数据将进入工作表,每当发生这种情况时,数据库必须自动更新。
onEdit
function of Google AppScript (I learned from here .), I could pickup when the file has changed.onEdit
功能(我从这里学习。),我可以在文件更改时进行拾取。 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.