![]() |
VOOZH | about |
There are a vast number of PostgreSQL clients available on the Internet. From standard Drivers to BI and Analytics tools, PostgreSQL is a popular interface for data access. Using the SQL Gateway included in our ODBC Drivers, you can now create PostgreSQL entry-points that you can connect to from any standard client.
To access Adobe Commerce data as a PostgreSQL database on Windows, use the CData SQL Gateway, the ODBC Driver for Adobe Commerce, and the MySQL foreign data wrapper from EnterpriseDB. In this article, we compile the foreign data wrapper in Visual Studio, install it as an extension, and query Adobe Commerce data from PostgreSQL Server.
If you have not already, first specify connection properties in an ODBC DSN (data source name). This is the last step of the driver installation. You can use the Microsoft ODBC Data Source Administrator to create and configure ODBC DSNs.
Adobe Commerce uses the OAuth 1 authentication standard. To connect to the Adobe Commerce REST API, obtain values for the OAuthClientId, OAuthClientSecret, and CallbackURL connection properties by registering an app with your Adobe Commerce system. See the "Getting Started" section in the help documentation for a guide to obtaining the OAuth values and connecting.
You will also need to provide the URL to your Adobe Commerce system. The URL depends on whether you are using the Adobe Commerce REST API as a customer or administrator.
Customer: To use Adobe Commerce as a customer, make sure you have created a customer account in the Adobe Commerce homepage. To do so, click Account -> Register. You can then set the URL connection property to the endpoint of your Adobe Commerce system.
Administrator: To access Adobe Commerce as an administrator, set CustomAdminPath instead. This value can be obtained in the Advanced settings in the Admin menu, which can be accessed by selecting System -> Configuration -> Advanced -> Admin -> Admin Base URL.
If the Use Custom Admin Path setting on this page is set to YES, the value is inside the Custom Admin Path text box; otherwise, set the CustomAdminPath connection property to the default value, which is "admin".
The MySQL remoting service is a daemon process that listens for clients' incoming MySQL connections. See the setup guide in the SQL Gateway overview to configure the MySQL Remoting service in the CData SQL Gateway.
The Foreign Data Wrapper can be installed as an extension to PostgreSQL, without recompiling PostgreSQL. If you are running PostgreSQL on a Unix-based system, you can use the PostgreSQL Extension Network (PGXN) to install the FDW, mysql_fdw. If you are running PostgreSQL on Windows, compile the extension to ensure that you are working with the latest version. Follow the steps below to make the necessary modifications to build the extension from Visual Studio:
To build the foreign data wrapper, do the following:
After you have obtained the necessary software and source code, you are ready to compile the extension with Visual Studio. Follow the steps below to create a project using the mysql_fdw source:
Follow the steps below to configure your project:
Follow the steps below to add the required dependencies:
postgres.lib libmysql.lib WS2_32.lib Secur32.libAdditionally, ensure that Inherit From Parent or Project Defaults is checked.
MyMySQLConnectorCInstallation\include MyPostgreSQLInstallation\MyPostgreSQLVersion\include\server\port\win32_msvc MyPostgreSQLInstallation\MyPostgreSQLVersion\include\server\port\win32 MyPostgreSQLInstallation\MyPostgreSQLVersion\include\server MyPostgreSQLInstallation\MyPostgreSQLVersion\include
After setting up a project, make the following changes to build mysql_fdw in Visual Studio:
#define dlsym(lib, name) (void*)GetProcAddress((HMODULE)lib, name) #define dlopen(libname, unused) LoadLibraryEx(libname, NULL, 0)
mysql_dll_handle = dlopen(_MYSQL_LIBNAME, RTLD_LAZY | RTLD_DEEPBIND);
mysql_dll_handle = dlopen("libmysql.dll", 0);
__declspec(dllexport) extern Datum mysql_fdw_handler(PG_FUNCTION_ARGS);
__declspec(dllexport) extern Datum mysql_fdw_validator(PG_FUNCTION_ARGS);
You can now select the Release configuration and build.
After you have compiled the DLL, follow the steps below to install the extension:
After you have installed the extension, follow the steps below to start executing queries to Adobe Commerce data:
C:\> psql -U postgres
postgres=#CREATE EXTENSION mysql_fdw;
postgres=# CREATE SERVER Adobe Commerce FOREIGN DATA WRAPPER mysql_fdw OPTIONS (host '127.0.0.1', port '3306');
postgres=# CREATE USER MAPPING for postgres SERVER Adobe Commerce OPTIONS (username 'admin', password 'test');
postgres=# CREATE SCHEMA Adobe Commerce_db;
postgres=# IMPORT FOREIGN SCHEMA "CData Adobe Commerce Sys" FROM SERVER Adobe Commerce INTO Adobe Commerce_db;
You can now execute read/write commands to Adobe Commerce:
postgres=# SELECT * FROM Adobe Commerce_db."products";
Download a free trial of the Adobe Commerce ODBC Driver to get started:
Download NowLearn more:
👁 Adobe Commerce IconThe Adobe Commerce ODBC Driver is a powerful tool that allows you to connect with live Adobe Commerce data, directly from any applications that support ODBC connectivity.
Access Adobe Commerce like you would a database - read, write, and update Customers, Inventory, Products, Orders, etc. through a standard ODBC Driver interface.