DBF<-->SQLite Exporter

Utilities like DBU, Make, IDE written in HMG/ used to create HMG based applications

Moderator: Rathinagiri

User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: DBF<-->SQLite Exporter

Post by Rathinagiri »

Hi,

It is not the .hbp file, but the .hbc file is important.

Further, I have updated to the new version of DBF <---> SQLite Explorer to export all the tables in a SQLite file into respective dbf files.

Note: Width of Field Names in DBF files is truncated to 10 characters.

Enjoy!
dbf2sqlite.zip
(1.14 MiB) Downloaded 899 times
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
bels79
Posts: 37
Joined: Fri Sep 09, 2011 8:01 am
DBs Used: DBF, MySQL

Re: DBF<-->SQLite Exporter

Post by bels79 »

rathinagiri, Chacal.GO I am grateful for the help, it can be run.


Chacal.GO wrote:Hello bels79 !

You just need to edit file: dbf2sqlite.hbp ( can be edited via HMG IDE )


If you dont have "HMGSQL LIB" just download from link below:
viewtopic.php?f=8&t=1562&p=12079&hilit=HmgSql#p12079


dbf2sqlite.hbp - before changes:

Code: Select all


main.prg
sqlite2dbf.prg

dbf2sqlite.hbp - After changes:

Code: Select all


main.prg
sqlite2dbf.prg

#
# libs
#
# 
-lhbsqlit3

#
# .hbc files
#
# 
hbsqlit3.hbc
dbf2sqlite.hbc

User avatar
IMATECH
Posts: 188
Joined: Sun May 27, 2012 9:33 pm
Location: Brazil: Goiânia-GO.

Re: DBF<-->SQLite Exporter

Post by IMATECH »

Hello bels79 !


Please: can you explain any dificulties found ?


Regards...
M., Ronaldo

By: IMATECH

Imation Tecnologia
bels79
Posts: 37
Joined: Fri Sep 09, 2011 8:01 am
DBs Used: DBF, MySQL

Re: DBF<-->SQLite Exporter

Post by bels79 »

I tried according to the instructions given, delete command "CFLAGS = -Wall -mno-cygwin -O3 " on file "makefile.gcc"



Chacal.GO wrote:Hello bels79 !


Please: can you explain any dificulties found ?


Regards...
User avatar
IMATECH
Posts: 188
Joined: Sun May 27, 2012 9:33 pm
Location: Brazil: Goiânia-GO.

Re: DBF<-->SQLite Exporter

Post by IMATECH »

Then... new instructions:

01 - Copy project to your samples HMG folder
-> \HMG\SAMPLES\Dbf2Sqlite

02 - Command Prompt: (or build from HMG ide)
\HMG\SAMPLES\..\..\build.bat Dbf2Sqlite.hbp

03 - Now you have built Dbf2Sqlite... enjoy
\HMG\SAMPLES\Dbf2Sqlite.exe

Regards...
M., Ronaldo

By: IMATECH

Imation Tecnologia
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: DBF<-->SQLite Exporter

Post by Rathinagiri »

Or simply use HMG-IDE, open and build the project.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
Hazael
Posts: 109
Joined: Thu Jun 24, 2010 11:37 am
Location: France

Re: DBF<-->SQLite Exporter

Post by Hazael »

rathinagiri wrote:Hi,

It is not the .hbp file, but the .hbc file is important.

Further, I have updated to the new version of DBF <---> SQLite Explorer to export all the tables in a SQLite file into respective dbf files.

Note: Width of Field Names in DBF files is truncated to 10 characters.

Enjoy!
dbf2sqlite.zip
Hello Rathinagiri,

I just download and tried the DBF->SQLite converter but it does not recognize datatype + (auto-increment) - It was introduced on this changelog:

2007-09-25 03:20 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
...
* harbour/source/rdd/dbf1.c
+ added support for AUTOINC (+), ROWVERSION (^), TIME (T), DAYTIME (@)
and MODTIME (=) fields
...

It is interesting feature - you should check it.

Could you please add it to this nice utility?
Thanks

Qatan
Harbour | GTWVT | MingW | Visual Studio Code
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: DBF<-->SQLite Exporter

Post by Rathinagiri »

Dear Qatan,

For your kind information, I am not using the RDD. I directly connect with hbsqlite library.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
Hazael
Posts: 109
Joined: Thu Jun 24, 2010 11:37 am
Location: France

Re: DBF<-->SQLite Exporter

Post by Hazael »

Hello Rathinagiri,

I think you didn't understand.
It talks about new datatypes in DBF fields. Before there were only C, L, N, M and D but now we have a few more. The auto increment is type | + | and is very useful.
What I wanted to express is that the DBF<-->SQLite Exporter utility does not know this new DBF datatype + so it gives an error (type not recognized or something like that...)
I was asking you if it is possible that you could update your nice utility to understand the new DBF datatypes. Do you think it is possible? I like your utility and I think it could support these new datatypes...

By the way I am considering to try some special features of SQLite:

1) Integration with ICU with localization features for finding "A" and "á" as the same thing: http://www.sqlite.org/src/artifact?ci=t ... README.txt
(also "a", "ã", "Â", "À", "â", etc... and goes to "o", "O", "ó", etc... etc...)

2) Integration with SQLCypher http://sqlcipher.net/ (I remember you succeded with this one, if I am not wrong)

3) FTS (Fast Text Search) feature: http://www.sqlite.org/fts3.html

I think SQLite is very good and what I like most is the simplicity of it (zero config), only one file for all tables and of course blazing fast. A query like this one in a big database is super fast:
SELECT * FROM table1 WHERE field1 LIKE '%core%' OR field2 LIKE '%core%' OR field3 LIKE '%core%' ORDER BY field4

The above query seeks for word "core" in many fields and in any part of the field way faster than using DBFNSX with OrdWildSeek()

Of course it demands a lot of research and try but a program using SQLite with the above features would be very nice. I would appreciate any previous experience with any of the above (of all of them)

Right now I can not do the above query to search for the following data (I am missing ICU component):

coré
corè
córe
côre
etc...

By the way you can use ICU component in the DBF files also:
2012-04-20 17:52 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
...
* harbour/src/codepage/cp_utf8.c
+ harbour/src/codepage/uc16def.c
+ harbour/src/codepage/utf8sort.c
* replaced UTF8ASC with new CP: UTF8EX
This CP uses character indexes instead of bytes one
and operates on unicode characters flags.
Tables for upper/lower conversions and upper/lower/alpha/digit
flags were generated automatically from
http://www.unicode.org/Public/UNIDATA/UnicodeData.txt
It also uses custom collation rules. It's very simple one
level sorting based on UTF8 C collation.
If someone needs some advanced sorting rules, then it's enough
to create copy of this cp with user custom version of UTF8_cmp()
and UTF8_cmpi() functions, i.e. they can be redirected to some
external library like ICU (icu-project.org).
...


Also I can not encrypt the database so anyone can open it and see/modify it with a simple utility what could cause inconsistencies not to mention it would not protect the information on the database being accessed by anyone (in special in a shared folder on the network).

The FTS feature would just be an extra.

Thanks for your help

Qatan
Harbour | GTWVT | MingW | Visual Studio Code
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: DBF<-->SQLite Exporter

Post by Rathinagiri »

Thanks a lot for the detailed explanation Qatan.

I didn't use DBF autoincrement fields. So I didn't know about that. I will dig into it and make use of it.

1. Regarding ICU, unfortunately HMG is not ready for Unicode implementation even though Harbour is. There are many places to be changed for unicode implementation.

2. SQLCipher is possible now. You can encrypt/decrypt the whole database on the fly without any hustle. You can download the library and details from here.

viewtopic.php?f=7&t=2416

3. Will FTS be possible without ICU?

Regarding encryption and decryption I have coded a small utility if you have installed the SQLCipher properly.
encryptsqlite.zip
(622.26 KiB) Downloaded 771 times
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
Post Reply