Exportar tabla MariaDB a texto con tabulares

HMG en Español

Moderator: Rathinagiri

Post Reply
jorge.posadas
Posts: 183
Joined: Mon May 19, 2014 7:43 pm
DBs Used: DBF, SQLite, MS-SQL, ACCESS, MariaDB (en proceso)
Location: Morelia, Mich. México
Contact:

Exportar tabla MariaDB a texto con tabulares

Post by jorge.posadas »

Grupo

Tengo una tabla en MariaBD con 90mil registros, y me han pedido que yo exporte esos 90mil registros a un archivo TXT delimitado por tabulares
¿cómo puedo hacer eso?

De antemano agradezco la ayuda
Cordialmente

POSADAS SOFTWARE
Jorge Posadas Ch.
Programador independiente
Morelia, Mich.
M é x i c o .
Movil +52 44 3734 1858
SKYPE: jorge.posadasch
Email: posoft@gmx.com
User avatar
serge_girard
Posts: 3309
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Exportar tabla MariaDB a texto con tabulares

Post by serge_girard »

Do While function + ? command

just like DBF !

Serge
There's nothing you can do that can't be done...
User avatar
vagblad
Posts: 173
Joined: Tue Jun 18, 2013 12:18 pm
DBs Used: MySQL,DBF
Location: Thessaloniki, Greece

Re: Exportar tabla MariaDB a texto con tabulares

Post by vagblad »

Hello Jorge

Here is a very draft example, assuming connection with the database is already established

Code: Select all

Local cTempString := ''
Local oRow, oQuery

cQueryString := 'SELECT * FROM yourTable "

oQuery := oServer:Query(cQueryString)
If oQuery:NetErr()
  memowrit(cError, oQuery:Error() + ' --- ' + cQueryString)
EndIf

If oQuery:LastRec() > 0
 For i := 1 to oQuery:LastRec()
  oRow := oQuery:GetRow(i)
  cTempString += oRow:FieldGet("Field 1") + ',' + oRow:FieldGet("Field 2") + ',' + oRow:FieldGet("Field X") + CRLF
 Next i
EndIf

memowrit("mariadb.txt",cTempString)
Vagelis Prodromidis
Email: vagblad@gmail.com, Skype: vagblad
User avatar
Ismach
Posts: 164
Joined: Wed Nov 28, 2012 5:55 pm
DBs Used: DBF, mySQL, Mariadb, postgreSQL, Oracle, Db2, Interbase, Firebird, and SQLite
Location: Buenos Aires - Argentina

Re: Exportar tabla MariaDB a texto con tabulares

Post by Ismach »

En lulgar de poner un caracter de separador de columnas pone solamente Ascii 9 ylisto, asi:

Code: Select all

Local cTempString := ''
Local oRow, oQuery

cQueryString := 'SELECT * FROM TuPedorraTabla"

oQuery := oServer:Query(cQueryString)
If oQuery:NetErr()
    memowrit(cError, oQuery:Error() + ' --- ' + cQueryString)
EndIf
If oQuery:RecCount() > 0
     For i := 1 to oQuery:RecCount() Step 1
         oRow := oQuery:GetRow(i)
        cTempString += oRow:FieldGet("Col1") + Chr(9) + oRow:FieldGet("Col2") + Chr(9) + oRow:FieldGet("ColZ") + hb_OsNewLine()
     Next i
EndIf
memowrit("TuPedorraTabla.plana.txt",cTempString)
Post Reply