Michael Yaeger
Michael Yaeger

Reputation: 824

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. 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. 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.

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. I'm fine with that last step, but I'm unsure of the steps to connect and retrieve data from the ODBC data source.

How can I connect to and extract Sage 100 data from an ODBC Data Source to write to a MySQL Database on another server?

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?


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.

Upvotes: 4

Views: 2725

Answers (1)

FunkMonkey33
FunkMonkey33

Reputation: 2248

It's actually very easy. Just establish an ODBC connection to the SOTAMAS90 DSN. Your connection string looks like this:

"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. Or you can install the 64-bit version of the driver, which can be found in your Sage directory, in the WKSetup folder.

After that just write code to SELECT * from each of the tables you need, and write them into your MySql database.

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. But it's slow. Much better performance if you can run a nightly ETL to populate your MySQL database and query that. Be sure to set foreign keys and create indexes for them after to define the tables.

Hope that helps.

Aaron

Upvotes: 1

Related Questions