Search code examples
mysqlwindowsdelphidelphi-2007zeos

Can select ... into outfile not save it into a file, but save it in blob instead


I want to do a select * from x into outfile 'c:/test.csv'.
But instead of saving into an outfile test.csv I want to save it into a blob field.

I'm starting the query from a client on Windows.
The MySQL server is on a server on Windows or Linux (can be both).
But I want to have the file client-side, not somewhere on the server.

BTW
The client software in written in Delphi 2007 and uses ZEOS to connect to the MySQL database on a remote server.

How do I get the outfile client side, instead of server side?


Solution

  • OK In case people want to know I made a workaround to the the TMS DBAdvGrid to export the CSV file.

    I added a new property to TAdvStringGrid

    public {properties}
    property HideCSVHeader: boolean read FHideCSVHeader write FHideCSVHeader;
    

    and changed the following code:

    procedure TAdvStringGrid.OutputToCSV(FileName:String;appendmode: Boolean; 
      Unicode: boolean);
    ....
    //changed this code further down the procedure:
    //for z := SaveStartRow to SaveEndRow do 
    //Into:
    
    MyStartRow:= SaveStartRow;
    if HideCSVHeader then Inc(MyStartRow);
    for z := MyStartRow to SaveEndRow do   
    

    Then when I call

    procedure TForm1.BtnExportClick(Sender: TObject);
    var
      Filename: string;
      succes: Boolean;
    begin
      succes:= True;
      if ExportSaveDialog.Execute then begin
        Filename:= ExportSaveDialog.FileName;
        try
          DBGridExportExact.Delimiter:= ';';
          DBGridExportExact.AlwaysQuotes:= True;
          DBGridExportExact.QuoteEmptyCells:= True;
          DBGridExportExact.SaveHiddenCells:= True;
          DBGridExportExact.HideCSVHeader:= True;
          DBGridExportExact.SaveToCSV(bestandsnaam);
        except
          succes:= False;
        end;
        if not(succes) then StatusLabel.Caption:= 'Error bla bla';
      end;
    end;