How to export data from tables "DBF" MySQL tables



Visit the New Harbour MiniGUI tutorial





with



DBF Table: listproduct.DBF


Table structure (fields)


many records (data)



Copy all records in a text file
(text_file.txt)

"Copy and Paste" source code... 
(dbf_to_mysql.prg)
procedure main()
close all
use listproduct.dbf
copy fields code,name_produ,price to text_file.txt delimited with " "
close all
return

Compile dbf_to_mysql.prg file like this:
c:\work>harbour dbf_to_mysql.prg
c:\work>hbmk2 dbf_to_mysql

Run dbf_to_mysql.EXE
c:\work>dbf_to_mysql.EXE <enter>



Open file: text_file.TXT
c:\work>notepad text_file.TXT <enter>


Copy "text_file.txt" in the directory database MySQL ...


with
Create Database (hardware_products)

and create 

MySQL Table: listproduct

"Copy and Paste" source code... 
drop database  hardware_products;
create database hardware_products;
show databases;
use hardware_products;
delimiter //
create procedure create_table_listproduct()
begin
    create table listproduct(
    code varchar(10),
    name_produ varchar(50),
    price double(8,2));
end //
delimiter ;
call create_table_listproduct();
describe listproduct;

Type and Run this command in "MYSQL"
mysql>LOAD DATA INFILE "text_file.txt" INTO TABLE listproduct FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n';


Type and Run this command in "MYSQL"
mysql>select * from listproduct;

and ...



Download the file work.rar and extract:
descargar el archivo comprimido work.rar y extraer los archivos:
dbf_to_mysql.prg
text_file.txt
listproduct.dbf