同步2个数据库
我有一个 MySQL 数据库和另一个在 MS SQL 上运行的数据库。 MySQL 是我在 Joomla 上运行的网站的后端数据库。 我有一个 ERP 来管理我的商店。该 ERP 由第三方在 .Net 中制作,
每当用户在我的网站下订单时,名为 theorders
的表就会更新。 订单详细信息必须刷新到 ERP 中的 orders
表中。 两个数据库的表结构完全不同,所以我自己做映射。
我的问题是:
- 我应该多久将数据从 MySQL 数据库传输到 MS SQL?
- 有人建议我可以编写一个 Web 服务,定期将数据泵送到 ERP 中的表中。所以我开始考虑 Nusoap Web 服务。这是正确的方法还是有更好的方法?
- 我还必须将库存相关信息从 ERP 检索到 MySQL 数据库。
I have a database in MySQL and another database that runs on MS SQL.
The MySQL is the backend database for my website running on Joomla.
I have an ERP running my store. This ERP is made by a 3rd party in .Net
A table called the orders
gets updated whenever a user places an order in my website.
The order details must get flushed to my orders
table in my ERP.
The table structure in the two databases are totally different so I will do the mapping myself.
My questions are:
- How frequently should I transfer the data from my MySQL database to MS SQL?
- Someone suggested that I could write a web service that would periodically pump data to my table in the ERP. So I started thinking about Nusoap webservices. Is this the right way or is there a better way to do it ??
- I will also have to retrieve inventory-related information from my ERP to my MySQL database.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
1:取决于您的数据更改频率以及您需要同步的频率(即取决于您的业务)。
2& 3:传输数据的 Web 服务可以正常工作。但除非你试图想出一个通用的解决方案,否则这听起来比它的价值要麻烦得多。
如果我这样做,我会将数据从 Sql Server 导出到一个文件,然后将该文件导入到 mysql (
mysql my_db < file.sql
)。以这种格式从 sql server 中获取数据并不那么容易(在 Sql Server 上没有与
mysqldump
等效的工具)。但请查看这个问题以获取一些想法。如果系统之间的数据本身是兼容的(如果列是等效的数据类型),则只需在 SQL Server 中创建一个以正确顺序导出数据的查询即可克服表结构差异。
事实上,您可以创建一个查询,其输出是要导入到 mysql 的 file.sql。例如,如下查询:
生成类似以下的输出:
我至少曾以这种方式从 sql server 导出过数据一次。
1: Depends on how often your data is changing, and how often you need to sync up (i.e., depends on your business).
2 & 3: A web service to transfer data could work just fine. But unless you're trying to come up with a general solution, this sounds like a lot more trouble than it's worth.
If I were doing this, I would export the data from Sql Server to a file, then import that file into mysql (
mysql my_db < file.sql
).Getting data OUT of sql server in this format isn't so easy (there's no equivalent to
mysqldump
on Sql Server). But check out this question for some ideas.If the data itself is compatible between systems (if the columns are equivalent data types), you can overcome the table structure differences by just creating a query in SQL Server which exports the data in the correct order.
In fact, you may be able to create a query who's output is the file.sql for import into mysql. For example, a query such as:
Produces output something like:
I've exported data from sql server that way on at least one occasion.
决定转移订单的频率是一项业务决策,而不是技术决策。但很难看出如果不尽快处理客户的订单,您可能会获得什么竞争优势,所以这应该是理所当然的。
如果不了解更多有关您的基础设施和架构的信息,我们无法为您提供有关方法的明确建议。我希望编写得当的 ERP 软件包能够包含用于导入和导出信息的接口。可惜的是,这样的期望常常令人困惑。如果您确实需要编写自己的界面,请避免使用 Web 服务。除非您有非常特殊的设置,否则所有 WS 都意味着需要更长的时间才能满足您的客户。我想我们已经同意这不是一个好主意。
同步 API 的注意事项:
尚未转移至 ERP
数据库。一面旗子笨拙,一面队列
也许更优雅。
不断识别订单
需要转移和
近乎实时地传输它们。
ERP 数据库不可用。
时尚让你不必
重写整个事情
因为结构的改变
您的一张桌子上。
必须从 MySQL 中提取
数据库,因为这似乎不太可能
第三方将允许您
将代码放入他们的数据库中。但
合同值得一读。
Deciding how often you transfer the order across is a business decision not a technical one. But it is hard to see what competitive advantage you might gain from not processing your customers' orders as soon as possible, so it ought to be a no brainer.
Without knowing a lot more about your infrastructure and architecture we cannot give you definitive advice about approach. I would expect a decently written ERP package to include interfaces for importing and exporting information. Alas such expectations are often confounded. If you do need to write your own interface, avoid web services. Unless you have a very peculiar set-up all WS will mean is that it will take longer to satisfy your customers. I think we have already agreed that is not a good idea.
Considerations for a Syncronization API:
have not been transferred to the ERP
database. A flag is clumsy, a queue
is perhaps more elegant.
continuously to identify orders
which need to be transferred and
transfer them in near-real time.
unavailability of the ERP database.
fashion so you do not have to
rewrite the entire thing just
because of a change to the structure
of one of your tables.
have to be pulled from the MySQL
database, as it seems unlikely that
the third party will allow you to
put code into their database. But
it's worth reading the contract.
好的,根据我得到的答复,我将重新表述我的问题,提供更多详细信息。
我有一个在 Joomla 和 Virtue mart 上运行的电子商务门户(不管它们是什么!!)
这里的后端数据库是MySQL。
我有一个我的朋友用.net编写的erp,那里使用的数据库是MSSQL
现在我要托管我的电子商务门户。
以下是将要采取的行动以及与行动
1 相关的问题:
一天开始时,我的朋友更新了 erp 表上的各种产品的库存
问题:
我希望 erp (MS SQL) 中更新的库存能够自动反映在我的网站数据库 (MySQL) 上。我该怎么做?
行动2:
人们来到我的网站并下订单。这些订单存储在我网站(MYSQL)的订单表中。
问题2:
我希望我的网站(MySQL)中的这些更新订单相关数据在我的erp(MS SQL)中的相应表上更新
更多关于我的erp和我的网站中的表的数据库结构完全不同
Okay based on the replies I got I will rephrase my question giving more details.
I have an eCommerce portal running on Joomla and Virtue mart (never mind what they are !!)
The backend database here is MySQL.
I have an erp written in .net by my friend and the Db used there is MSSQL
Now I am going to host my eCommerce portal.
Following are actions that will take place and questions related to the actions
Action 1:
At the start of the day my friend updates inventory of various products on and erp table
question:
I want the updated inventory from the erp (MS SQL) to get reflected on my website database (MySQL) automatically. How do I do it ?
Action 2:
People come to my site and place orders.These orders are stored in an order table in my website(MYSQL).
Question 2:
I want these update orders related data from my website (MySQL) to be updated on a corresponding table in my erp (MS SQL)
More over the db structures of the tables in my erp and my website are completely different