Page 1 of 1

MARIADB Export Rowset

Posted: Tue Feb 23, 2021 11:10 pm
by Adolfo
Hi fivewinners

Is there a metod in Mariadb to export a row set to a txt file.
Just like Tdolphin with...

oQry:=cSvr:Query("select * from datos")
oExp:=oQry:Export( EXP_TEXT, "C:\XXXXX\EXPORT" )
oExp:Start()
oExp:Close()

or something like that.

Thanks in advance

Re: MARIADB Export Rowset

Posted: Wed Feb 24, 2021 12:00 pm
by nageswaragunupudi
Please try

Code: Select all | Expand


cText := oCn:SqlToText( cSql )
MEMOWRIT( cFile, cText )
 

Re: MARIADB Export Rowset

Posted: Thu Feb 25, 2021 11:47 am
by Adolfo
Thanks..
Works great...

Re: MARIADB Export Rowset

Posted: Thu Feb 25, 2021 6:03 pm
by MOISES
Mr. Rao,

Can we please have this SqlToText for ADO?

Thank you

Re: MARIADB Export Rowset

Posted: Thu Feb 25, 2021 10:57 pm
by nageswaragunupudi
Please try

Code: Select all | Expand

cText := ""
AEval( RsGetRows( oRs ), { |a| cText += ( FW_ArrayAsList( a, Chr(9) ) + CRLF ) } )
MEMOWRIT( cFile, cText )
 

Re: MARIADB Export Rowset

Posted: Fri Feb 26, 2021 1:24 am
by MOISES
Yes, it works correctly, it exports the rows.

But what I would really need would be the backup() method for ADO, to save in a txt file the content of the database in SQL mode INSERT INTO CITIES( CODE, CITY ) VALUES ( "1", "Madrid") ...

Would it be possible please?

Re: MARIADB Export Rowset

Posted: Sat Jul 16, 2022 8:59 am
by MOISES
Hi,

Is there any progress?

Thank you. Best regards

Re: MARIADB Export Rowset

Posted: Sat Jul 16, 2022 3:05 pm
by nageswaragunupudi
For small and medium size tables, please try:

Code: Select all | Expand

  //BACKUP
   MEMOWRIT( cBackupFile, FW_ValToExp( RsGetRows( oRs ) ) )


   // RESTORE

   //1. Create the new table with same column specs and same column order

   aData := &( MEMOREAD( cBackUpFile ) )
   for each aRow in aData
      oCn:Execute( "INSERT INTO NEWTABLE VALUES " + FW_ValToSql( aRow ) )
   next
 

Re: MARIADB Export Rowset

Posted: Thu Jul 21, 2022 8:55 am
by MOISES
Thank you very much, I have replaced memwrite and memoread by hb_, which are supposed to be faster.

But there is a problem: if the order of the fields in the table is not the same, then it fails, because the INSERT does not indicate the field.

Is it possible to include the field in the INSERT? Thank you.

Re: MARIADB Export Rowset

Posted: Tue Jul 26, 2022 10:09 am
by MOISES
Up!

Re: MARIADB Export Rowset

Posted: Wed Aug 03, 2022 10:57 am
by MOISES
Up! Thnks