Convert DBF to MYSQL - Converter DBF para MYSQL

114 views
Skip to first unread message

valt...@valtecom.com.br

unread,
Sep 15, 2023, 10:48:08 AM9/15/23
to Harbour Minigui
Good morning dear friends,
Does anyone know of a tool that converts DBF to MYSQL? I found some but they are paid or don't work, I have one made in Harbor/Minigui called DBF2SQL but it isn't working anymore.
If anyone has a tool that does this job and can make it available I would be grateful.
Hugs.
Valteçom
Uberaba MG Brazil

Bom dia caros amigos,
Alguém conhece alguma ferramenta que converta DBF para MYSQL? Eu encontrei algumas mas são pagas ou não funcionam, eu tenho uma feita em Harbour/Minigui chamada DBF2SQL mas não está funcionando mais.
Se alguém tiver uma ferramenta que faça esse trabalho e puder diponibilizar eu agradeço.
Abraços.
Valteçom
Uberaba MG Brasil

Bob Burns

unread,
Sep 15, 2023, 11:02:14 AM9/15/23
to minigu...@googlegroups.com

MYSQL will import a CSV file so can you export a CSV file from your DBF database?

Regards

Bob

Bob F Burns G3OOU, G-QRP 6907, @BobFBurns
Crystal Palace Radio & Electronics Club: https://cprec.chessck.co.uk/
Admin/sales site: http://www.g3oou.co.uk/
Technical site: www.qsl.net/g3oou
--
Visit our website on https://www.hmgextended.com/ or https://www.hmgextended.org/
---
You received this message because you are subscribed to the Google Groups "Harbour Minigui" group.
To unsubscribe from this group and stop receiving emails from it, send an email to minigui-foru...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/minigui-forum/ad8ab247-97b6-4a5c-b7bd-3c49c02ede43n%40googlegroups.com.

Dan Campbell

unread,
Sep 15, 2023, 12:31:28 PM9/15/23
to Harbour Minigui
Hi Valtecom,

I haven't tried it yet, but there's an Xailer download that seems to do this.

It's from 2013 , so you'd have to try it to know for sure.



The description is

Xailer Open DBF2SQL Project - Convert DBF Tables to MariaDB/MySQL Databases

José M. C. Quintas

unread,
Sep 15, 2023, 12:35:42 PM9/15/23
to minigu...@googlegroups.com
Create you own routine.

Source code as an example using ADO

Make your own tests about codepage and others.

It is part of my application, then, if compile will show that need more
functions, but using name you can create them.

Or you can create a file and import using heidisql or another tool.

#define SQL_MAX_CMDINSERT   256000

FUNCTION CopyDbfToSQL( cTable, lTransfere, lCria, lZera, cNewTable )

   LOCAL oStru
   LOCAL cSQL, xValue, nCont, cSQLFix
   LOCAL lBegin := .T., cTxt, cKeyName
   LOCAL cnGERAL := ADOLocal()
   LOCAL nSelect := Select()

   IF ! File( cTable + iif( ".DBF" $ Upper( cTable ), "", ".DBF" ) )
      RETURN Nil
   ENDIF
   hb_Default( @lCria, .F. )
   hb_Default( @lZera, .F. )
   hb_Default( @cNewTable, cTable )
   cTable      := Upper( cTable )
   SELECT 0
   USE ( cTable ) ALIAS thisdbf
   oStru    := dbStruct()
   cKeyName := "ID" + iif( Left( cTable, 2 ) $ "JP,HL", Substr( cTable,
3 ), cTable )
   USE
   cSQL := "CREATE TABLE IF NOT EXISTS " + cNewTable + " ( " + cKeyName
+ " INT(9) NOT NULL AUTO_INCREMENT, "
   FOR nCont = 1 TO Len( oStru )
      IF oStru[ nCont, DBS_NAME ] != cKeyName
         cSQL += oStru[ nCont, DBS_NAME ] + " "
         DO CASE
         CASE oStru[ nCont, DBS_TYPE ] == "N"
            IF oStru[ nCont, DBS_DEC ] == 0
               cSQL += " INT( " + Ltrim( Str( oStru[ nCont, DBS_LEN ] )
) + " ) DEFAULT 0"
            ELSE
               cSQL += " DECIMAL( " + Ltrim( Str( oStru[ nCont, DBS_LEN
] ) ) + " , " + Ltrim( Str( oStru[ nCont, DBS_DEC ] ) ) + " ) DEFAULT 0"
            ENDIF
         CASE oStru[ nCont, DBS_TYPE ] == "C"
            IF oStru[ nCont, DBS_LEN ] < 250
               cSQL += " VARCHAR( " + Ltrim( Str( oStru[ nCont, DBS_LEN
] ) ) + " ) DEFAULT '' "
            ELSE
               cSQL += " TEXT"
            ENDIF
         CASE oStru[ nCont, DBS_TYPE ] == "D"
            cSQL += " DATE " // DEFAULT '0000-00-00'"
         CASE oStru[ nCont, DBS_TYPE ] == "M"
            cSQL += " TEXT "
         ENDCASE
         cSQL += " , "
      ENDIF
   NEXT
   cSQL += " PRIMARY KEY ( " + cKeyName + " )"
   cSQL += " )"
   cSQL += ";"
   SayScroll( "Salvando no SQL." + cTable )
   IF lCria
      cnGERAL:ExecuteNoReturn( cSQL )
   ENDIF
   IF lZera
      cnGERAL:ExecuteNoReturn( "TRUNCATE TABLE " + cNewTable )
   ENDIF
   IF ! lTransfere
      SELECT ( nSelect )
      RETURN Nil
   ENDIF
   SELECT 0
   USE ( cTable ) ALIAS thisdbf
   GrafTempo( "Processando " + cTable )
   cSQLFix := "INSERT INTO " + cNewTable + " ( "
   FOR nCont = 1 TO FCount()
      cSQLFix += FieldName( nCont )
      IF nCont != FCount()
         cSQLFix += ", "
      ENDIF
   NEXT
   cSQLFix += " ) VALUES "
   cTxt := ""
   DO WHILE ! Eof()
      GrafTempo( RecNo(), LastRec() )
      Inkey()
      cSQL := "( "
      FOR nCont = 1 TO FCount()
         xValue := FieldGet( nCont )
         DO CASE
         CASE ValType( xValue ) == "N"
            cSQL += NumberSQL( xValue )
         CASE ValType( xValue ) == "D"
            cSQL += DateSQL( xValue )
         CASE ValType( xValue ) == "C"
            xValue := SQLValidString( xValue )
            cSQL += StringSQL( xValue )
         OTHERWISE
            cSQL += "NULL"
         ENDCASE
         IF nCont != FCount()
            cSQL += ","
         ENDIF
      NEXT
      cSQL += " )"
      IF Len( cTxt ) == 0
         cTxt += cSQLFix
         lBegin := .T.
      ENDIF
      IF ! lBegin
         cTxt += ", "
      ENDIF
      lBegin := .F.
      cTxt += cSQL
      IF Len( cTxt ) > SQL_MAX_CMDINSERT
         cnGERAL:ExecuteNoReturn( cTxt )
         cTxt := ""
      ENDIF
      SKIP
   ENDDO
   IF Len( cTxt ) != 0
      cnGERAL:ExecuteNoReturn( cTxt )
   ENDIF
   USE
   SELECT ( nSelect )

   RETURN Nil

Note when creating you own routine:

- define codepage on connection

- define codepage on database (mysql default is not the same on all
versions)

- insert many records as possible, one by one is slow

- check data after write, about codepage

- command limit from station depends on mysql setup, may be 4MB or more,
on this routine I fix to 256KB.


José M. C. Quintas

Otto Haldi GMAIL

unread,
Sep 15, 2023, 12:36:25 PM9/15/23
to minigu...@googlegroups.com

Here you will find a lot of tools about DBF Files:  https://www.whitetown.com/products/

--
Visit our website on https://www.hmgextended.com/ or https://www.hmgextended.org/
---
You received this message because you are subscribed to the Google Groups "Harbour Minigui" group.
To unsubscribe from this group and stop receiving emails from it, send an email to minigui-foru...@googlegroups.com.

priadi andika

unread,
Sep 15, 2023, 9:08:00 PM9/15/23
to valt...@valtecom.com.br, Harbour Minigui
Dear Group 
please looking for  in c:\minigu\sample\advanced\mysqlclient\ 
application migrasi DBF to Mysql  with hmg programing 

hopefully it's useful

Best Regard
Supriadi
Indonesia



--
Visit our website on https://www.hmgextended.com/ or https://www.hmgextended.org/
---
You received this message because you are subscribed to the Google Groups "Harbour Minigui" group.
To unsubscribe from this group and stop receiving emails from it, send an email to minigui-foru...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages