MARIADB Export Rowset

MARIADB Export Rowset

Postby Adolfo » Tue Feb 23, 2021 11:10 pm

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
;-) Ji,ji,ji... buena la cosa... "all you need is code"

http://www.xdata.cl - Desarrollo Inteligente
----------
Asus TUF F15, 32GB Ram, 2 * 1 TB NVME M.2, GTX 1650
User avatar
Adolfo
 
Posts: 860
Joined: Tue Oct 11, 2005 11:57 am
Location: Chile

Re: MARIADB Export Rowset

Postby nageswaragunupudi » Wed Feb 24, 2021 12:00 pm

Please try
Code: Select all  Expand view

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

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10626
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: MARIADB Export Rowset

Postby Adolfo » Thu Feb 25, 2021 11:47 am

Thanks..
Works great...
;-) Ji,ji,ji... buena la cosa... "all you need is code"

http://www.xdata.cl - Desarrollo Inteligente
----------
Asus TUF F15, 32GB Ram, 2 * 1 TB NVME M.2, GTX 1650
User avatar
Adolfo
 
Posts: 860
Joined: Tue Oct 11, 2005 11:57 am
Location: Chile

Re: MARIADB Export Rowset

Postby MOISES » Thu Feb 25, 2021 6:03 pm

Mr. Rao,

Can we please have this SqlToText for ADO?

Thank you
Saludos / Regards,

FWH 20.04, Harbour 3.2.0 dev (r1909261630) y BCC 7.40
MOISES
 
Posts: 838
Joined: Wed Aug 22, 2007 10:09 am

Re: MARIADB Export Rowset

Postby nageswaragunupudi » Thu Feb 25, 2021 10:57 pm

Please try
Code: Select all  Expand view
cText := ""
AEval( RsGetRows( oRs ), { |a| cText += ( FW_ArrayAsList( a, Chr(9) ) + CRLF ) } )
MEMOWRIT( cFile, cText )
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10626
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: MARIADB Export Rowset

Postby MOISES » Fri Feb 26, 2021 1:24 am

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?
Saludos / Regards,

FWH 20.04, Harbour 3.2.0 dev (r1909261630) y BCC 7.40
MOISES
 
Posts: 838
Joined: Wed Aug 22, 2007 10:09 am

Re: MARIADB Export Rowset

Postby MOISES » Sat Jul 16, 2022 8:59 am

Hi,

Is there any progress?

Thank you. Best regards
Saludos / Regards,

FWH 20.04, Harbour 3.2.0 dev (r1909261630) y BCC 7.40
MOISES
 
Posts: 838
Joined: Wed Aug 22, 2007 10:09 am

Re: MARIADB Export Rowset

Postby nageswaragunupudi » Sat Jul 16, 2022 3:05 pm

For small and medium size tables, please try:

Code: Select all  Expand view
  //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
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10626
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: MARIADB Export Rowset

Postby MOISES » Thu Jul 21, 2022 8:55 am

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.
Saludos / Regards,

FWH 20.04, Harbour 3.2.0 dev (r1909261630) y BCC 7.40
MOISES
 
Posts: 838
Joined: Wed Aug 22, 2007 10:09 am

Re: MARIADB Export Rowset

Postby MOISES » Tue Jul 26, 2022 10:09 am

Up!
Saludos / Regards,

FWH 20.04, Harbour 3.2.0 dev (r1909261630) y BCC 7.40
MOISES
 
Posts: 838
Joined: Wed Aug 22, 2007 10:09 am

Re: MARIADB Export Rowset

Postby MOISES » Wed Aug 03, 2022 10:57 am

Up! Thnks
Saludos / Regards,

FWH 20.04, Harbour 3.2.0 dev (r1909261630) y BCC 7.40
MOISES
 
Posts: 838
Joined: Wed Aug 22, 2007 10:09 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 91 guests