Our Biggest Sale Is Here
Up to 70% Off
Get the Deal

How to connect wpDataTables to MySQL, MS SQL and PostgreSQL databases

Say your WordPress site runs on one server, and your company’s stock levels live in an MS SQL database on another, with your customer list in PostgreSQL. You don’t need to copy that data into WordPress. Add each database as a separate connection in wpDataTables, and every table you create can read its data straight from the database you choose.

Which databases can I connect?

You can connect as many MySQL, MS SQL and PostgreSQL databases as you need, on the same server as WordPress or on any other server your site can reach. Each table uses one connection, so different tables on the same page can show data from different databases.

  • MS SQL connections need SQL Server 2012 or newer.
  • For MS SQL, your server needs a PHP driver for SQL Server, and you choose the installed one in Driver. Ask your host which driver your server has.
  • The database server has to accept connections from your web server, so check its firewall and user permissions.

How do I add a separate database connection?

Go to wpDataTables → Settings, open the Separate DB connection tab, fill in the connection details, test them and click Save Changes.

  1. Open the tab. Go to wpDataTables → Settings and open the Separate DB connection tab.
  2. Add a connection. Add a new connection and fill in the fields from the table below.
  3. Test it. Click Test DB settings. wpDataTables tries to log in and tells you whether the connection works.
  4. Save the settings. Click Save Changes.
Field What to enter
Connection Name A name you’ll recognize in the table wizard, for example Stock (MS SQL).
Vendor MySQL, MS SQL or PostgreSQL.
Driver For MS SQL, the driver installed on your server. dblib is selected by default.
Name The name of the database.
Host The address of the database server: a domain name or an IP address.
Port Only if the server doesn’t use the default port: 3306 for MySQL, 1433 for MS SQL, 5432 for PostgreSQL.
User and Password The login of a database user. A user with read-only access is enough for tables you only show.
Default Connection Turn it on for the connection the table wizard should select first.

Read how to configure the wpDataTables settings for the other settings tabs.

The Separate DB connection tab in wpDataTables Settings with a new MS SQL connection called Stock (MS SQL) filled in
A new MS SQL connection on the Separate DB connection tab: (1) the tab, (2) Add New Connection, (3) Test DB settings, (4) Save Changes. The connection details are examples.

How do I create a table from another database?

Choose the database in the Connection list at the top of the table wizard, then create the table as usual. The connection applies to everything the wizard creates from that point:

The Create a Table screen of wpDataTables with the Connection list open, showing WP Connection and a separate database connection
The Create a Table screen: (1) the Connection list, where you choose WP Connection or one of your separate database connections before you pick a table type.

Write the query in the syntax of the database you connect to. For example, MS SQL uses TOP and square brackets around names, while MySQL uses backticks. Placeholders such as %VAR1% work the same in every database.

What should I remember about database connections?

Add each external MySQL, MS SQL or PostgreSQL database once in wpDataTables → Settings → Separate DB connection, test it with Test DB settings, and mark the one you use most as the Default Connection. Then pick the database in Connection at the top of the table wizard. MS SQL needs SQL Server 2012 or newer and the right PHP driver on your server.

Wait, Before You Download!

To get your hands on wpDataTables Lite, please enter your email address below. We’ll send you a direct download link and keep you updated on existing features along with helpful tips and tricks!

By continuing, I accept Privacy Policy and T&C
Mail Box