}。
我想做的是:
我试图从本地数据库导出,并使用phpMyAdmin导入到联机数据库,但我收到错误消息:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''CHEA B C13279', 'CHE', 'CHK', 'Reaction kinetics can be studied by', '0', ' ' at line 1
我尝试过导出不同类型的文件格式,如SQL、CSV、XML等,以及使用INSERT、UPDATE和REPLACE的自定义SQL文件,但我失败了。我的想法是:
以SQL INSERT file格式导出本地和联机数据库,然后使用Python文件I/O和字符串格式比较这两个文件,并为UPDATE数据库表中的现有数据和INSERT新数据数据库表创建两个新文件。
我目前为止的Python代码:
^{pr2}$
运行上述脚本后,我得到的输出为:
在更新文件中只写入1行。
在“插入文件”中写入在线文件的所有条目-1。
注意:
1我在本地机器上编辑了超过15k个条目,因此在比较两个数据库时不可能只有一个条目不同。
2在Insert file中,应该写入不重复的条目,但它从联机数据库中写入了所有条目,更新文件中的条目除外。
三。实际上,数据库的file或Primary Key行中的唯一性都是在头几个字母中。但我不知道如何使用两个文件中每行的第一个字母来比较行。编辑:
两个SQL文件中的文本类似于:
在线数据库文件示例('CHEA B C13279', 'CHE', 'CHK', 'Reaction kinetics can be studied by', 0),
('CHEA B C13281', 'CHE', 'CHK', 'Half - life is independent', 0),
('CHEA B C15590', 'CHE', 'Elo', 'A horizontal plank has a rectangular block', 0),
('PHYPTEST3217', 'PHY', 'PT', 'Two particles of same mass and charge', 0),
('PHYMP34780', 'PHY', 'MP', 'What id the momentum of X-rays', 0),
('MATCUS10678', 'MAT', 'DC', 'If $\\int x^{-3}.{5^{x^\\frac{1}{^2}}}dx{5^{x^\\frac{1}{^2}}} $ then $ k $ is', 0),
本地数据库文件示例('CHEA B C13279', 'CHE', 'CHK', 'Reaction kinetics can be studied by', '0'), #Unchanged content
('CHEA B C13281', 'CHE', 'CHK', 'This is edited and updated', '0'), #Updated content
('CHEA B C15590', 'CHE', 'Elo', 'This is edited and updated', '0'), #Updated content
('PHYPTEST3217', 'PHY', 'PT', 'This is edited and updated', 0), #Updated content
('PHYMP34780', 'PHY', 'MP', 'What id the momentum of X-rays', 0), #New contents
('MATCUS10678', 'MAT', 'DC', 'If $\\int x^{-3}.{5^{x^\\frac{1}{^2}}}dx{5^{x^\\frac{1}{^2}}} $ then $ k $ is', 0), #New contents
('CHEVHV14696', 'CHE', 'TCE', 'Variation of heat of reaction with temperature is given by Kirchhoff''s equation, which is :', '0'), #New contents
('MAT2D35456', 'MAT', '2D', 'The shortest distance between the parabolas $y^{2}=4x$ and $y^{2}=2x-6$ is', '0'), #New contents
('PHYHaT33353', 'PHY', 'TP', 'What is the unit $pV$ in the gas equation $pV = \\ce{RT}?$', '0', '$\\ce{Nm}$', '0'), #New contents
('PHYWEP4745', 'PHY', 'WEP', 'A rubber ball of mass m and radius r is submerged', '0'), #New contents
所有这些都可以看作元组。所以我有两个列表(文件),本地有55263个元组,在线有37548个元组。每个元组有相等数量的元素,即21个元素,这些元素是字符串、一些特殊字符(如$、^等)和整数。在
请用Python或者使用SQL查询来帮助我解决这个问题。我是个语言初学者。在
提前谢谢你!在