您的位置 首页 golang

「GoLang效率」我的第一个Go效率工具:自动纠错并同步数据

工作需要,从第三方平台下载统计数据到公司内部数据库。

最好的路径应该是:

1、利用第三方OpenAPI直接获取数据;

2、和自己数据库中的数据比较,看哪些需要同步

3、有需要同步的,则同步过来

「GoLang效率」我的第一个Go效率工具:自动纠错并同步数据

但是,咨询并查阅第三方OpenAPI后发现,没有统计数据可下载。

那就改变一下:

1、手工下载统计数据 — zip文件到本地

2、后续同步过程使用Go代码写的工具去实现

2.1、检查zip文件时间和本地数据库时间,如果大于数据库最新数据时间,则需要同步

2.2、如果需要同步,则解压zip文件,生成csv文件。

2.3、同步csv文件到本地数据库对应的表。但有个坑:csv文件title和行实际数据不一定一致。

需要每行检查并纠正。

2.4、数据库中有和csv文件对应的模板表,从模板表创建对应的数据表。

2.5、把csv对应的行数据insert into对应的表–中间表

3、检查本地数据库中间表,检查是否需要实际插入目标表。如果有则插入。

因为数据必须完整,故所有数据库操作采用事务方式处理。

「GoLang效率」我的第一个Go效率工具:自动纠错并同步数据

本工具暂时只有处理最新zip文件,和最新中间表。并没有做到处理所导出数据zip文件,没有检查所有本地中间表文件。待优化,不过因为一周只需要执行一次,故暂时满足使用了。

主函数如图:

「GoLang效率」我的第一个Go效率工具:自动纠错并同步数据

主程序

「GoLang效率」我的第一个Go效率工具:自动纠错并同步数据

临时表到目标表

好了,以后不用手工同步数据了,只需要每周一次的手工下载统计文件。

也可以把工作交出去了。

很容易打包成exe文件。发布这这方面还是比Python方便一点。

工作中,好多手工都尽量工具化。提高工作效率。


我是【程序员黑洞】,一个程序员。正在学GoLang,用GO给自己写效率工具。

欢迎关注我,欢迎留言交流。

文章来源:智云一二三科技

文章标题:「GoLang效率」我的第一个Go效率工具:自动纠错并同步数据

文章地址:https://www.zhihuclub.com/86797.shtml

关于作者: 智云科技

热门文章

评论已关闭

38条评论

  1. If you re prescribed Cialis at a certain dosage, it s important to take the same dosage if you use this medication in liquid form

  2. In addition, a pooled analysis tadalafil users were stratified according to age 75 vs This may not seem like a big deal but turning a dial is far more convenient than pressing a button up, up, up or down, down, down

  3. Although ADCIRCA has not been shown to increase bleeding times in healthy subjects, use in patients with bleeding disorders or significant active peptic ulceration should be based upon a careful risk-benefit assessment

  4. This age range was selected as clomiphene is used most commonly during the reproductive years.

  5. Luo can garlic increase penis size Jia smiled, still holding the Google mobile phone on the table, went back to his office and brought several old mobile phones, namely Motorola V3, Nokia 7610, and Apple 4th generation.

  6. Major compounds of silymarin or milk thistle extract Acne is a common side effect of using Winstrol, and it is very likely

  7. The pharmacist is deemed responsible for identifying, resolving, and preventing medication related problems such as untreated indications, improper drug selection, inadequate dosing, adverse drug reactions, interactions and medication use without indication

  8. I only talk to one or two people in my gym so I don t eff around either; strictly business in the gym naltrexone macrobid macrocrystals monohydrate price They include the Jaguar C Type which was produced between 1951 and 1953, later succeeded by the D Type

  9. We have repeated this experiment using the Click it TUNEL kit under the same conditions previously described in our original publication 1 and our results are consistent

  10. viagra vialis shark tank The appointment signals XiaomiГў s intention to take on Appleand Samsung Electronics Inc

  11. Resource utilization data were obtained primarily from published literature and a physician survey including expert opinion from ATAC Steering Committee members 785L Liquid Topical 3

  12. Assessing these parameters in pre and post chemotherapy longitudinal samples might be also useful in possibly determining the ovarian reserve in women using IUS contraception at the time of diagnosis given that the number of these women has gone up the recent years

  13. Evaluated by measuring Ki67 protein by immunohistochemistry and aurora kinase alpha gene expression

  14. Densitometry analysis are shown in graphs n 7, P E, Plasma nitrate and nitrite levels in control n 10 and EC P2Y 2 R KO mice n 11

  15. but I m ER not so haven t had Kadcyla Sane moved back to Silicon Valley where her husband works and she loves being part of such a diverse and vibrant culture

  16. It can be hard to say whether medications are causing falls; usually what is more accurate to say is that these medications are increasing fall risk, by affecting balance and stability

  17. Only a few studies have evaluated the chronic effects of ОІ blockers in the context of PH

  18. Single dose vials must be diluted before infusion However, the potential use of anthrax as a biological weapon has increased fear of this pathogen

  19. 17 Other herbal drugs compete for the same cytochrome pathway as commonly used anaesthetic agents e

  20. Genome wide association study identifies eight new risk loci for polycystic ovary syndrome

  21. I ve been on clomid several times com 20 E2 AD 90 20Viagra 20Olx 20Kenya 20 20Funny 20Viagra 20Prescription funny viagra prescription The deal is understood to have been struck in January at the World Economic Forum in Davos, Switzerland, at a meeting between Mr Blair and senior figures from the Peruvian government, including Luis Miguel Castilla, the finance minister

网站地图