hernad / harbour

agile harbour (a.k.a hernad's fork)
Other
1 stars 3 forks source link

How to start using PostgreSQL? #1

Open hernad opened 4 years ago

hernad commented 4 years ago

It seems this is most important question for fellow developers who wants escape from DBFs

hernad commented 4 years ago

This could be your first contact with world of PostgreSQL :)

https://github.com/hernad/harbour/blob/master/tests/sddpg/test1.prg

hernad commented 4 years ago

If you are using ADS (Advantage database server), this is how I think about possible options for migration:

If you are accessing ADS tables with your harbour application, than you can make migration program which will export that data to another data source. I have great experience with PostgreSQL, so you can follow my path :)

At my home github page https://github.com/hernad, you can see all of the relevant projects.

My suggestion is to study source code, starting from F18, suppose It is subject you are familiar at functional level (accounting).

I am aware that Bosnian language used is problem, but there is google translate :)

If you are small business like I am (1-2 developers), migrations from point 0 is mission impossible. Focus on changing data layer (ADS DBF -> PostgreSQL). If you succeed on that, you will make great step toward modernization of your application.

You can continue to use your old interface and gradually change parts you consider most important .

So I recommend that you change data layer within harbour application. After you change that, you can access your data from every other system.

After that you are free to go wherever you want :)

hernad commented 4 years ago

DBF tables My application uses DBF tables. But only for operations of entering new documents like (pratically temporary storage)

hernad commented 4 years ago

I have found recent conversation on topic on harbour-users group. Here are most imporant notes from that conversation:

Connection to PostgreSQL database is achieved through TPostgreSQL and/or SQLMIX/sddpg. The main thing is that both interfaces share the same PostgreSQL connection (from TPostgreSQL instance). Demonstration in tests/sddpg/test1.prg.

I suggest you to look into the code of our accounting app F18

This part is actually library (it is candidate to be included into agile harbour):

https://github.com/hernad/F18/tree/4/core_sql

These are usages in fetching data (creating report):

*A) directly through SQL interface**

B) The same functionality through SQLMIX layer, "old school" (as DBF developers are used to fetch data)

The update functionality is an different story. That demands more changes in legacy DBF code. We use DBF tables as temporary local tables for new document input. When temporary data is entered into DBF (in this example kalk_pripr.dbf), it is pushed to the SQL server table (SQL tables kalk, kalk_doks):

https://github.com/hernad/F18/blob/4/kalk/kalk_azuriranje.prg#L537

The source code, variables naming, comments are written by Bosnian to Bosnians. Sorry for that.