Import the data from the XML files into a MySQL database(将数据从 XML 文件导入 MySQL 数据库)
问题描述
我想构建一个 Rails 应用程序来将数据从 XML 文件导入到 MySQL 数据库中.有什么帮助吗?
I would like to build a Rails application to import the data from a XML file into a MySQL database. Any help?
推荐答案
为什么需要 Rails 来完成这个任务?XML 文件会被用户上传吗?如果没有,那么您可能只需要一个 ruby 脚本.
Why do you need Rails for this task? Will the XML file be uploaded by users? If not, then a script in ruby may be all you need.
在所有情况下,您都需要:
In all cases you need to:
- 解析传入的 XML 并设置某些对象或变量的属性
- 将这些属性或变量保存在数据库中.
对于第一个任务,您可以使用 ReXML,LibXML,Nokogiri 或任何其他 XML 解析器库.
For the first task you may use ReXML, LibXML, Nokogiri or any other XML parser library.
对于第二个(如果您不在 Rails 中使用 ActiveRecord),您可能会看到 mysql2 gem 的文档.
For the second (if you don't use ActiveRecord in Rails), you may see the documentation for the mysql2 gem.
如果您对这些库有任何疑问,请随时提出更多问题.
Feel free to ask further questions if you have any problems with these libraries.
这篇关于将数据从 XML 文件导入 MySQL 数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:将数据从 XML 文件导入 MySQL 数据库


基础教程推荐
- ERROR 2006 (HY000): MySQL 服务器已经消失 2021-01-01
- 如何在 SQL Server 的嵌套过程中处理事务? 2021-01-01
- Sql Server 字符串到日期的转换 2021-01-01
- SQL Server 中单行 MERGE/upsert 的语法 2021-01-01
- 使用pyodbc“不安全"的Python多处理和数据库访问? 2022-01-01
- 无法在 ubuntu 中启动 mysql 服务器 2021-01-01
- SQL Server:只有 GROUP BY 中的最后一个条目 2021-01-01
- 在 VB.NET 中更新 SQL Server DateTime 列 2021-01-01
- 将数据从 MS SQL 迁移到 PostgreSQL? 2022-01-01
- SQL Server 2016更改对象所有者 2022-01-01