Steve Bergman wrote:
Is it possible to dump an SQLite table in a format something like this?

INSERT INTO employee (last_name, first_name, mi, username, id, extension, home_phone, cell_phone, status, email_primary, email_secondary) VALUES ('Jones', 'John', NULL, 'jjones', 6, '108/14', '555-1212', '525-2123', 'a', '[EMAIL PROTECTED]', NULL);

I have a need to move data between DBMS's where the field order may not be known.

Thanks,
Steve Bergman



The program to do this is not very complex, so I can imagine that many people have written it. This is what it does.

    sqlite3_prepare(...)         - compile your SELECT

    sqlite3_column_count         - count of columns
    for each column
      sqlite3_column_name        - form array of column names

    while TRUE
      rc = sqlite3_step          - execute SQL statement

      if (rc == SQLITE_ROW)
         store each column value in an array
      end
      if (rc = SQLITE_DONE
        sprintf(out, "INSERT INTO .... ;\n", column names, column values);
        write out to a file
        sqlite3_reset
      end
    end
     sqlite3_finalize

Reply via email to