Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Using QProcess with mdb-tools
Forum Updated to NodeBB v4.3 + New Features

Using QProcess with mdb-tools

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vezprog
    wrote on last edited by
    #1

    I understand this isn't an mdb-tools forum (although, there is no forum denoted towards the linux software mdb-tools unfortunately).

    I have posted before about trying to convert a .mdb file into a csv file or trying to access a .mdb file via database commands. What I have resulted in doing is using a QProcess that uses mdb-tables, mdb-export, all apart of mdb-tools to convert my .mdb file on a table basis.

    here is the code for how I run the QProcess:

    @
    QProcess gettables;
    QString tbl_cmd = "mdb-tables -d, '";
    QString cmd;

    // generate arguments
    cmd = tbl_cmd.append(filename);
    cmd = cmd.append("'");
    
    // get table names
    gettables.start(cmd);    // start cmd
    gettables.waitForFinished(-1);          // wait till done...
    QString output = gettables.readAllStandardOutput();     // get std output
    QString strerror = gettables.readAllStandardError();    // get std output errors
    qDebug() << output;     // print output
    qDebug() << strerror;   // print errors
    

    @

    where filename is a variable that gets set from a dialog box that the user selected the file name.

    If I simply type in the terminal window outside of my Qt App:
    mdb-tables -d, 'file name'

    The output is successful and it displays the tables in a comma delimited format.

    Now, when I try to run my QProcess through my Qt code, I get the following error:
    "Can't alloc filename, Couldn't open database" which is flagged by the std_error debug statement.

    I guess I am trying to figure out if I am using QProcess correctly or if its an mdb-tools issue. For some reason I feel like I am since I tried a simple printf statement saying hello world and the qDebug() printed out the std out statement correctly.

    Anyone have any thoughts?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      Yes. Pass each and every argument to QProcess as a separate string in the arguments stringlist.

      So, that is, change your code to this:
      @
      QProcess gettables;
      QString cmd = "mdb-tables";
      QStringList argss;
      args << "-d"; //removed the comma that was there in your original code, did it really belong there?
      args << filename;

      // get table names
      gettables.start(cmd, args); // start cmd
      gettables.waitForFinished(-1); // wait till done...
      QString output = gettables.readAllStandardOutput(); // get std output
      QString strerror = gettables.readAllStandardError(); // get std output errors
      qDebug() << output; // print output
      qDebug() << strerror; // print errors
      @

      Futhermore, considder if you can switch to the asynchronic API instead of using waitForFinished.

      1 Reply Last reply
      0
      • V Offline
        V Offline
        vezprog
        wrote on last edited by
        #3

        Unfortunately, I had tried that previously using the arguments and and the command. So it seems it doesn't like something within the process initialization or something of that sort because I used your exact code and I get the same error. I just find it weird that I can use the same exact command on the command line and get an output, yet when I try to use it through a QProcess, it flags an error.

        Back to the drawing board!

        p.s. the comma is supposed to be there, -d is the delimiter flag, and the "," is the separator. My goal was to get the table names in a list and create the csv files accordingly using the split function. :P

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved