Mediator with MySql

Moderator: Rathinagiri

User avatar
sudip
Posts: 1444
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India
Has thanked: 4 times

Mediator with MySql

Post by sudip » Mon Dec 28, 2009 9:23 am

Hi Friends,

Again an "old" idea is running in my mind ;)

Recently I started writing software with Sql Database (mainly with Sqlite). Struggling with arrays and Sql commands for more than one month, I realized, it's very time consuming for me to write software with Sql database within a very short time. So, yesterday I again started re-writing those pre-matured software with DBFCDX ;)

Meanwhile, I heard about Mediator from my friend Jayadev. He is using it successfully with MySql (AFIK, which is free :) ). With Mediator we can use RDD with MySql :o But, as the RDD library comes in .lib form. I don't know how to use it with HMG :roll:

Can anyone help us regarding this subject?

It's also helpful for me if anyone can share his/her experience about Mediator. (Jayadev my friend, are you hearing me? :) )

My special thanks to Jayadev for giving information about this product :)

Thanks in advance :)

(Rathi, I am not sure if it is correct to put this post in "HMG General Help" section or not :? So, please correct me if I am wrong :) )

With best regards.

Sudip
Last edited by sudip on Mon Dec 28, 2009 9:27 am, edited 1 time in total.
With best regards,
Sudip

User avatar
Rathinagiri
Posts: 5181
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 142 times
Been thanked: 131 times
Contact:

Post by Rathinagiri » Mon Dec 28, 2009 9:27 am

If you want to just convert a .lib file into a .a file, it can be easily done with GNU dlltools.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

User avatar
sudip
Posts: 1444
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India
Has thanked: 4 times

Post by sudip » Mon Dec 28, 2009 9:30 am

Thanks Rathi,

As far I remember, you told me about the tool before :) I shall try it :)

Moreover, as I learned how to use Sql Database with HMG from YOU, I am thinking why you are not using Mediator? Your answer is extremely important to me :)

With best regards.

Sudip
With best regards,
Sudip

User avatar
Rathinagiri
Posts: 5181
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 142 times
Been thanked: 131 times
Contact:

Post by Rathinagiri » Mon Dec 28, 2009 11:07 am

I use Grid control to show my query/report results.

Recently, I am on a small accounting software (there are still people who re-invent the wheels!) for one of my friends.

He wanted to keep his accounts to be single user, portable, small, simple and clean. So, I preferred HMG and SQLite. :)

Don't laugh on seeing this software. It is based on traditional Indian book keeping (daybook, ledger, ....) which shows cash as credit balance in daybook ;). Further he wanted me to created only up to trial balance. :) He wanted to integrate purchase of materials and payment to suppliers. Therefore I had added some material management also.

Just after running the software, it would ask for a file (what else? the database file!). Select .sqlite file enclosed herewith. You can copy this .sqlite template file for creating a new account book for a small company. Allowed voucher types as of now are Receipt, Payment, Purchase, Journal.

For moving to next year, copy your .sqlite data file to a new file and delete all the transactions. Then enter the opening trial balance. That's all.

This way he can have only a .exe file for application and .sqlite file for data file. Keep it in a flash drive. So cool! Isn't it?

Here is the source code. Compile and have fun!
Attachments
acsqlite.zip
(273.29 KiB) Downloaded 303 times
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

User avatar
sudip
Posts: 1444
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India
Has thanked: 4 times

Post by sudip » Mon Dec 28, 2009 3:18 pm

Thanks a lot Rathi!!! :D
A real-life accounting software!!! :o :) I am sure everybody (including me) must be benefited from your code. :D Friend, your source code has high commercial value in Indian market. Please include this code in our up-coming HMG book :)

I am sending my un-finished Payroll system software with source code. The .exe file will automatically create required database with tables with checking whether they exist or not. Then create accounting year and select the accounting year and .... I shall be very happy, if you please check Emp.prg and send your comments regarding the simple method I used for positioning of different controls :)
SalarySql.zip
(74.24 KiB) Downloaded 312 times
With best regards.

Sudip
With best regards,
Sudip

User avatar
Rathinagiri
Posts: 5181
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 142 times
Been thanked: 131 times
Contact:

Post by Rathinagiri » Tue Dec 29, 2009 12:05 pm

Hi Sudip,

Nice and consistent way of I/O through out all your programs is the thing which I like very much.

I had checked Emp.prg and I am sure the way you handle the placement of controls will be really useful. (Field Pos and Label pos).

IMHO, your memory utilization is more and it can be avoided by some simple optimizations. For example, you query all the employee master records while getting inside and store them in a separate array variable, which is not required.

While using SQL, it will be optimistic to query/retrieve only the record set we require at that particular time. So, while entering the employee master window, it is necessary to find out the names of the employees and not all the details.

I was also doing the same thing when I had started using SQL. Now, I use all the HMG controls as the data holders and I use only local variables to handle the record set. This can be seen from my above programs (especially material master.) In this way, it is possible to call the new material master wherever you use to enter some particular information about a material.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

User avatar
sudip
Posts: 1444
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India
Has thanked: 4 times

Post by sudip » Wed Dec 30, 2009 4:43 am

Thanks a lot Rathi,

Thanks a lot for the tips :D

I need your help in this area. :) Especially my way of storing all data into an array for a large table will face problem for large tables ;) I am now leaving my office. I shall be back after a few hours and check Materials Master module :)

Thank you again.

With best regards.

Sudip
With best regards,
Sudip

Tristan
Posts: 40
Joined: Sun Jul 19, 2009 2:15 pm

Post by Tristan » Wed Dec 30, 2009 6:40 am

Thanks Mr. Rathi,

How to compile ? I can't find main.hpj :)

Regards,
Tristan

User avatar
sudip
Posts: 1444
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India
Has thanked: 4 times

Post by sudip » Wed Dec 30, 2009 4:47 pm

Hi Tristan,
Please try with HMG 3.0.0 test version. Open Main.hbp file with IDE. Hope it will solve your problem :)

Hello Rathi,
I checked Matmast.prg. I hope I understand the point, ie., it's better to store value from the query result-set array to the form controls directly :) Another thing I also found, you run sql query every time when go to next record. In my program I mimicked array as dbf file :lol:

Regarding consistent I/O or GUI in my programs, I want to offer my users most simple solution I can give. There is always better solution than my solution, but I try to offer a very simple solution with minimalistic windows control (may be this is one of the reasons, why I like HMG so much).

It has 2 side-effects ;) , my end-users feel at home when I give them next brand new programs. This is the positive side-effect :). And negative side-effect is that, they thought a brand-new software as an extension of old program (just an upgrade!!!) and try to decrease my development charge :( :lol:

Thanks a lot friend. :)

BTW, have you thought a way how to change sql table structure automatically?

With best regards.

Sudip
With best regards,
Sudip

User avatar
Rathinagiri
Posts: 5181
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 142 times
Been thanked: 131 times
Contact:

Post by Rathinagiri » Fri Jan 01, 2010 2:32 pm

Hi Sudip,

Yes. I invoke the SQL query as and when we require the data. This method would have some drawbacks too. In the case of remote server concept, the bandwidth may the problem. May be we should download the master data once and store locally in an array. Otherwise, for SQLite and LAN operated MySQL databases, SQL queries can be made as and when the data is required.

For changing table structure there is a command "alter table". I think we can write a safe user defined function for this.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

Post Reply