FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour sql 2 dbf
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
sql 2 dbf
Posted: Fri Nov 27, 2009 11:54 AM

How I can converte a sql database into dbf ?

Best Regards, Saludos



Falconi Silvio
Posts: 1789
Joined: Tue Oct 11, 2005 05:01 PM
Re: sql 2 dbf
Posted: Fri Nov 27, 2009 03:09 PM

Silvio.

1.-create connection with database (mysql/mssql/firebird/postgreesql)
2.-create a structucture of dbf based in the structure of table sql.
3.-read the table sql record by record and insert in table dbf the fields of the recordset.

NOTE: you can use ADO for the read the data in sql.

sorry for my bad english.

salu2
carlos vargas

Salu2

Carlos Vargas

Desde Managua, Nicaragua (CA)
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Re: sql 2 dbf
Posted: Fri Nov 27, 2009 05:29 PM

sorry but I not Know the structure of sql file
I have only this file xxx.sql and I must converte it on dbf

Best Regards, Saludos



Falconi Silvio
Posts: 1789
Joined: Tue Oct 11, 2005 05:01 PM
Re: sql 2 dbf
Posted: Fri Nov 27, 2009 05:41 PM
usually the sql file have the structure inside.
and have the sql statement insert into for each row in the table.

if you do not know the structura of the table, I doubt that a program can know this unless defined in the same sql.

this is a example for a sql from mysql:

note in file the code for delete the table if this exist.
then create table and insert the row with data.

Code (fw): Select all Collapse
-- Tiempo de generación: 09-11-2009 a las 15:54:43
-- Versión del servidor: 5.0.51
-- Versión de PHP: 4.4.4
-- 
-- Base de datos: `bdc`
-- 

-- --------------------------------------------------------

-- 
-- Estructura de tabla para la tabla `categorias`
-- 

DROP TABLE IF EXISTS `categorias`;
CREATE TABLE IF NOT EXISTS `categorias` (
  `id` int(11) NOT NULL auto_increment,
  `idcategoria` varchar(10) NOT NULL default 'C0',
  `nombrec` varchar(250) NOT NULL default '',
  `orden` int(10) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=16 DEFAULT CHARSET=latin1 AUTO_INCREMENT=16 ;

-- 
-- Volcar la base de datos para la tabla `categorias`
-- 

INSERT INTO `categorias` VALUES (1, 'C01', 'Cumpleaños', 2);
INSERT INTO `categorias` VALUES (2, 'C02', 'Aniversario', 1);
INSERT INTO `categorias` VALUES (3, 'C03', 'Día de la Madre', 11);
INSERT INTO `categorias` VALUES (4, 'C04', 'Felicitaciones', 3);
INSERT INTO `categorias` VALUES (5, 'C05', 'Corporativo', 4);
INSERT INTO `categorias` VALUES (6, 'C06', 'Mejorate Pronto', 5);
INSERT INTO `categorias` VALUES (7, 'C07', 'Buena Suerte', 6);
INSERT INTO `categorias` VALUES (8, 'C08', 'Nacimientos', 7);
INSERT INTO `categorias` VALUES (9, 'C09', 'Románticos', 8);
INSERT INTO `categorias` VALUES (10, 'C10', 'Muchas Gracias', 9);
INSERT INTO `categorias` VALUES (11, 'C11', 'Pensando en Ti', 10);
INSERT INTO `categorias` VALUES (12, 'C12', 'Día del Padre', 12);
INSERT INTO `categorias` VALUES (14, 'C14', 'Ocaciones Especiales', 14);
INSERT INTO `categorias` VALUES (13, 'C13', 'Niños', 13);
INSERT INTO `categorias` VALUES (15, 'C15', 'Centros para Piñatas', 15);


salu2
carlos vargas
Salu2

Carlos Vargas

Desde Managua, Nicaragua (CA)
Posts: 3358
Joined: Fri Oct 07, 2005 08:20 PM
Re: sql 2 dbf
Posted: Fri Nov 27, 2009 06:51 PM

Carlos:

I think Silvio is looking for a class/function like DIRECTORY() but for TABLES instead DBFs.

Silvio:

Search for ADOX in saint google.

Regards.

SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Re: sql 2 dbf
Posted: Sat Nov 28, 2009 10:35 AM

I CAN SEND YOU MY FILE IF YOU WANT TRY TO CONVERTE IT
i NOT kNOW THE STRUCTURE OF THIS FILE

A SCHOOL GIVE ME A FILE BIBLIO.SQL i MUST CONVERTE IT INTO DBF FILE BECUASE i ALLREADY MADE A BIBLIO APPLICATION ON 2001
IT I FOUND THE SOLUTION TO CONVERTE IT INTO DBF i CAN SAVE ALL RECORDS ON MY DBF FILE AND THIS SCHOOL CAN USE MY APPLICATION

Best Regards, Saludos



Falconi Silvio
Posts: 326
Joined: Sun Oct 09, 2005 05:22 PM
Re: sql 2 dbf
Posted: Sat Nov 28, 2009 04:35 PM

Silvio, sendme your 'database.sql' backup, i will try it.

Posts: 1789
Joined: Tue Oct 11, 2005 05:01 PM
Re: sql 2 dbf
Posted: Sun Nov 29, 2009 12:07 AM

Silvio,

I can try, please end me the file sql. :-)
karlos.vargas at gmail.com

salu2
carlos vargas

Salu2

Carlos Vargas

Desde Managua, Nicaragua (CA)
Posts: 12
Joined: Thu Nov 17, 2005 02:53 AM
Re: sql 2 dbf
Posted: Sun Nov 29, 2009 02:42 PM

Try a software name SQL Converter

Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Re: sql 2 dbf
Posted: Sun Nov 29, 2009 03:01 PM

carlos I sent you the file at donbxxxx.... email

Best Regards, Saludos



Falconi Silvio
Posts: 12
Joined: Thu Nov 17, 2005 02:53 AM
Re: sql 2 dbf
Posted: Sun Nov 29, 2009 03:05 PM

carlos vargas,

According to your information, if i want to online read sql data into my FWH program for further processing, Must I use Advantage Database Server, can I use advantage local server (because it is free) or any other method.

Right now I am using SQL CONVERTER to convert particular table into CSV file and then import to DBF for further processing, but it is batch conversion and not controlled by records
I hope i can retrieve by FWH program because it is more flexible.

Posts: 1789
Joined: Tue Oct 11, 2005 05:01 PM
Re: sql 2 dbf
Posted: Mon Nov 30, 2009 03:27 AM

Ready!

the procedure is easy.

1.-install mysql.
2.-SLQYog.
3.-Open SQLYog and open the mysql database.
4.-open you sql file, copy the content. an paste in the rigth windows in SQLYog.
5.-click rigth button mouse in the rigth windows in SQLYog and select run execute all query. (this procedure is similar to restore the dump file)
6.-install the odbc mysql 3.51 and create a connexion in the ODBC Origen Data in control panel. ( i call 'mytes' )
7.-open excel an select the data menu, and get external data option, then select new query database.
8.-select the mytest connexion and select the table biblio, follow the wizard.
9.-then the data is imported to sheet in excel.
10.-save the excel file as dbf file.
11.- you must modify the DBF file according to your needs.

i send the files dbf create in a zip to you email.

sorry for my very bad english.

salu2
carlos vargas

Salu2

Carlos Vargas

Desde Managua, Nicaragua (CA)
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Re: sql 2 dbf
Posted: Mon Nov 30, 2009 08:58 AM

thanks carlos

Best Regards, Saludos



Falconi Silvio
Posts: 824
Joined: Thu Oct 13, 2005 07:39 AM
Re: sql 2 dbf
Posted: Mon Nov 30, 2009 10:24 AM
Silvio,

you can do it also from your app.

Hi Silvio,

if you edit your sql-file, you find the structure at the top with the index keys:

Code (fw): Select all Collapse
-- Table structure for table `biblio`
-- 

CREATE TABLE IF NOT EXISTS `biblio` (
  `NumIns` int(10) NOT NULL auto_increment,
  `INVENTARIO` double(15,0) default NULL,
  `NUM_ING` double(15,0) default NULL,
  `DAT_ING` date default NULL,
  `TITOLO` varchar(255) default NULL,
  `TIPO` varchar(255) default NULL,
  `VOLUME` double(15,0) default NULL,
  `DIQUANTI` double(15,0) default NULL,
  `AUTORI` varchar(255) default NULL,
  `NUM_COPY` double(7,0) default NULL,
  `SITUAZIONE` double(7,0) default NULL,
  `CONSERVA` varchar(255) default NULL,
  `SALA` varchar(255) default NULL,
  `ARMADIO` varchar(255) default NULL,
  `RIPIANO` varchar(255) default NULL,
  `P_COPER` double(15,2) default NULL,
  `VALORE` double(15,2) default NULL,
  `FORNITORE` varchar(255) default NULL,
  `EDITORE` varchar(255) default NULL,
  `MESE` varchar(255) default NULL,
  `ANNO` double(15,0) default NULL,
  `PAGINE` double(15,0) default NULL,
  `FORMATO` double(15,0) default NULL,
  `ISBN` varchar(50) default NULL,
  `DEWEY` varchar(255) default NULL,
  `DEWDESC` varchar(255) default NULL,
  `SOGGETTO` varchar(255) default NULL,
  `ABSTRACT` varchar(255) default NULL,
  PRIMARY KEY  (`NumIns`),
  UNIQUE KEY `INVENTARIO` (`INVENTARIO`),
  UNIQUE KEY `NUM_ING` (`NUM_ING`),
  KEY `NUM_COPY` (`NUM_COPY`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=4246 ;


Create a dbf with the same structure, connect with your sql-server, read the data and save them in your dbf. I don´t have the sql-commands in my mind, but you can try to use the sqlwin rdd you can find here the forum.

Hope it helps
kind regards

Stefan
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: sql 2 dbf
Posted: Mon Nov 30, 2009 10:39 AM

Dear Mr.Stefan,

If I am not wrong, I understand that Mr.Silvio is having a .sql file, which actually is a sql dump file. (It has the table structure as well as the data in it). He needs to read the data from the .sql file and then transfer that data to a DBF file.

Mr.Silvio ?

Regards
Anser