3

I'm using MariaDB ODBC driver version 3.0.2 for Windows(on Windows 10) and can't get excel (Excel 2013) to query the database. I'm able to connect to my MariaDB server using HeidiSQL and query just fine, and my PHP application can query just fine. Now I would like to start pulling data for analytics.

I've setup the DSN using the "ODBC Data Source" tool under Administrative Tools in the control panel. I've just left all of the options blank. Below are some screenshots of how I setup the DSN.

Screen 1/5 Screen 2/5 Screen 3/5 Screen 4/5 Screen 5/5

When trying to setup the connection in Excel, I go to the data tab and from the "From Other Sources" drop down, I click Microsoft Query.

From MS Query

Then I select my data source (DSN) from the list and click "OK". Then I get two errors. The first error says "String data, right-truncated" and the second error says "Couldn't read this file". Screenshots below.

First Err Second Err

I'm not sure what is causing this. I've tried using the servers IP address and the servers resolvable name, and I've tried specifying a database. I've also tried specifying a connection character set and selecting the option for using compression. I've also tried enabling dynamic cursors and the option to return matched rows instead of affected rows. Nothing has made any changes.

UPDATE: This is still an issue for me. 6/21/2018

  • I have the same problem. Do you have any solution? Thanks in advance. – Jorge Martinez S. Jul 1 '18 at 12:42
  • 1
    No, I have not been able to find a solution yet. Even with updating to the newest version of the driver. This is one of the last things keeping me back from using MariaDB for more projects at work and I would really like to get it solved. . – Matthew Goheen Jul 1 '18 at 15:15
  • @JorgeMartinezS Read the MySQL Connector Docs for Using Connector/ODBC with Microsoft Applications: Gerneral advice: Every Table needs a PK (best is integer with autoincrement) and a timestamp column (default current timestamp and on update current timestamp) and in ODBC Driver "Return matched rows instead of affected" (Option=3) needs to be activated. With this settings mysql works like a charm with ms access and that should fit for MariaDb too.. – ComputerVersteher Jul 21 '18 at 11:42
  • @ComputerVersteher That did help me get a little further with this. But I'm still not able to write custom queries. It seems like I will only be able to pull one full table at a time. What I would like to be able to do is write a query selecting specific columns from multiple tables and use the where clause to filter the result set, just like i can when using Microsoft's SQL Server. – Matthew Goheen Jul 23 '18 at 13:21
0

I've figured out how to execute custom queries against MariaDB in Excel.

  1. Create your DSN using the "ODBC Data Sources (32-bit)" desktop app and leave all options as the default, except the connection page settings and "Return matched rows instead of affected".
    Matched rows
  2. In Excel, on the sheet you want the query to show up on, on the data tab, select "From Other Sources" -> "From Data Connection Wizard".
    Connection Wizard
  3. In the dialog that pops up, select "ODBC DSN" and click "Next".
  4. Find the DSN you created earlier and click "Next".
  5. Now you need to select a table, just one. (We will change this later)
  6. Click "Next", then "Finish", then "OK". The data from your table should populate the sheet, starting in what ever cell you specified before hitting that last "OK".

Okay, That's great! But how do I run a custom query with joins and a where clause? Read on my friend.

  1. Select any cell in the table that resulted from the above steps.
  2. In the design tab (should have opened when you clicked into the table) select the "Properties" button.
    enter image description here
  3. Click the "Connection Properties" button beside the "Name" field.
    enter image description here
  4. Now, on the "Definition" tab, in the "Command text:" field, you can paste in your query.
    enter image description here

I've tested this with basic joins and where statements. Everything seemed to work fine, so this should be enough to get you started. I have not tested sub-queries or any other advanced features yet.

|improve this answer|||||

Not the answer you're looking for? Browse other questions tagged or ask your own question.