简体   繁体   English

将Sage 100数据从ODBC数据源同步到MySQL数据库

[英]Sync Sage 100 Data from an ODBC Data Source to a MySQL Database

I am trying to setup remote access to the data of Sage 100 Advanced ERP for use within a website running on a MySQL database. 我正在尝试远程访问Sage 100 Advanced ERP的数据,以便在MySQL数据库上运行的网站中使用。 I only need to get inventory levels for products, so it's a read-only application. 我只需要获得产品的库存水平,因此它是一个只读应用程序。

As I understand it, Sage 100 comes with an ODBC driver that can allow remote access to Sage's flat-file data storage by creating a database view. 据我了解,Sage 100附带了一个ODBC驱动程序,可以通过创建数据库视图来远程访问Sage的平面文件数据存储。 What I need to do is copy a few fields from that data on the Sage server over to the web server hosting the website. 我需要做的是将Sage服务器上的数据中的几个字段复制到托管该网站的Web服务器。

To automate this process, I assume I'll need to setup a cron job on the web server that runs a PHP script (preferred language) executing SQL queries that connect to the remote server, extract the needed data, and write it to the appropriate tables in the MySQL database. 为了自动化这个过程,我假设我需要在运行PHP脚本(首选语言)的Web服务器上设置一个cron作业,执行连接到远程服务器的SQL查询,提取所需的数据,并将其写入相应的MySQL数据库中的表。 I'm fine with that last step, but I'm unsure of the steps to connect and retrieve data from the ODBC data source. 我对最后一步很好,但我不确定从ODBC数据源连接和检索数据的步骤。

How can I connect to and extract Sage 100 data from an ODBC Data Source to write to a MySQL Database on another server? 如何从ODBC数据源连接并提取Sage 100数据以写入另一台服务器上的MySQL数据库?

Or, is there a way to sync/mirror the ODBC Data Source to a MySQL Database on a separate server that I could then use to copy data over to the website's database? 或者,有没有办法在单独的服务器上同步/镜像ODBC数据源到MySQL数据库,然后我可以使用它将数据复制到网站的数据库?


Note: MySQL has documentation on pulling data FROM MySQL using ODBC , but no info on how to import data TO MySQL using ODBC on an external server. 注:MySQL有对文档拉动使用ODBC从MySQL数据 ,但对如何使用ODBC导入数据 MySQL在外部服务器上没有信息。

It's actually very easy. 这实际上非常简单。 Just establish an ODBC connection to the SOTAMAS90 DSN. 只需建立与SOTAMAS90 DSN的ODBC连接即可。 Your connection string looks like this: 您的连接字符串如下所示:

"DSN=SOTAMAS90; UID=MyUserId; PWD=MyPassword; Company=ABC" “DSN = SOTAMAS90; UID = MyUserId; PWD = MyPassword; Company = ABC”

Note that by default Sage installs a 32-bit version of the driver, which means you must target your application to 32 bits. 请注意,默认情况下,Sage会安装32位版本的驱动程序,这意味着您必须将应用程序定位到32位。 Or you can install the 64-bit version of the driver, which can be found in your Sage directory, in the WKSetup folder. 或者,您可以在WKSetup文件夹中安装64位版本的驱动程序,该驱动程序可以在Sage目录中找到。

After that just write code to SELECT * from each of the tables you need, and write them into your MySql database. 之后,只需从您需要的每个表中将代码写入SELECT *,然后将它们写入MySql数据库。

I don't really know MySql well, but in SQL Server you can set up a Linked Server, point it to SOTAMAS90, and then query the SQL Server database instead of the ODBC driver. 我不太了解MySql,但在SQL Server中,您可以设置链接服务器,将其指向SOTAMAS90,然后查询SQL Server数据库而不是ODBC驱动程序。 But it's slow. 但它很慢。 Much better performance if you can run a nightly ETL to populate your MySQL database and query that. 如果你可以运行每晚的ETL来填充你的MySQL数据库并查询它,那就更好了。 Be sure to set foreign keys and create indexes for them after to define the tables. 在定义表之后,务必设置外键并为它们创建索引。

Hope that helps. 希望有所帮助。

Aaron 亚伦

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM