Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2012-02

Data persistance in CGI projects

7 messages · 5 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Luciano de Souza

Hello all,

For desktop environments, there are mature projects on data persistance. Press Objects, TiOPF... desktop developers can be proud of the tools they have.

What about CGI environments? Is there something already developed? Yes, we can use SQLDB. It's really a very good component. However, we need to write lots of SQL. The dream would be something like:

user := TUser.create;
user.name := 'Luciano';
user.age := 36;
user.insert;

I can hide all the SQL statements behind a custom TUser class. I can implement it. However, before writing this clear code, I will have to type a set of SQL statements. In other words, to simplify, it would be necessary to create a mother clas whose properties and methods would be use for my custom TUser class.

Of course, it is only a possible approach. I believe this pattern is called ActiveRecord. I confess I know little about persistance patterns. There is also the DAO pattern. Well, there are certainly several patterns.

My questions concerns exactly to it:

1. What are the alternatives for a CGI environment using a productive data persistance? What are your suggestions in terms of units, class or either strategies, including the model, the view and the controller?
2. If CGI with Frepascal is still starting and consequently, there aren't powerful tools and, therefore, code needs to be implemented, which pattern do you recommend? ActiveRecord? DAO? Another?

Well, before starting something, the first step is to listen and I am sure, here there is people with a significant higher background than me!

Luciano

Reply by email

Michael Van Canneyt
to Luciano de Souza
Luciano de Souza wrote 14 lines
Hello all, For desktop environments, there are mature projects on data persistance. Press Objects, TiOPF... desktop developers can be proud of the tools they have. What about CGI environments? Is there something already developed? Yes, we can use SQLDB. It's really a very good component. However, we need to write lots of SQL. The dream would be something like: user := TUser.create; user.name := 'Luciano'; user.age := 36; user.insert;

Why not use tiOPF for this as well ? It works just as well in CGI environments.

Michael.

Reply by email

Luciano de Souza
to Michael Van Canneyt

Actually, reading the tiOPF, I found the support for Firebird, Microsoft SQL Server, Oracle, but not for PostgreSQL. This is the first reason. I really don't know how proper tiOPF is when we focuses on CGI development. At a first look, the project seemed to be very complex to use, but of course, I may be wrong.

Michael Van Canneyt wrote 27 lines
On Sun, 26 Feb 2012, Luciano de Souza wrote: > Hello all, > > For desktop environments, there are mature projects on data > persistance. Press Objects, TiOPF... desktop developers can be proud > of the tools they have. > > What about CGI environments? Is there something already developed? > Yes, we can use SQLDB. It's really a very good component. However, we > need to write lots of SQL. The dream would be something like: > > user := TUser.create; > user.name := 'Luciano'; > user.age := 36; > user.insert; Why not use tiOPF for this as well ? It works just as well in CGI environments. Michael. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

Jorge Aldo G. de F. Junior
to Luciano de Souza

You can use rtti and create a base class that knows how to save/load itself from sql database...

2012/2/26 Luciano de Souza :

Show quoted text 41 lines
Actually, reading the tiOPF, I found the support for Firebird, Microsoft SQL Server, Oracle, but not for PostgreSQL. This is the first reason. I really don't know how proper tiOPF is when we focuses on CGI development. At a first look, the project seemed to be very complex to use, but of course, I may be wrong. Em 26-02-2012 13:29, Michael Van Canneyt escreveu: > > > On Sun, 26 Feb 2012, Luciano de Souza wrote: > >> Hello all, >> >> For desktop environments, there are mature projects on data persistance. >> Press Objects, TiOPF... desktop developers can be proud of the tools they >> have. >> >> What about CGI environments? Is there something already developed? Yes, >> we can use SQLDB. It's really a very good component. However, we need to >> write lots of SQL. The dream would be something like: >> >> user := TUser.create; >> user.name := 'Luciano'; >> user.age := 36; >> user.insert; > > > Why not use tiOPF for this as well ? It works just as well in CGI > environments. > > Michael. > _______________________________________________ > fpc-pascal maillist  -   > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > _______________________________________________ fpc-pascal maillist  -   http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

Sven Barth
to Luciano de Souza: Actually, reading the tiOPF, I found the support for Firebird, Microsoft SQL Server,…
Luciano de Souza wrote 5 lines
Actually, reading the tiOPF, I found the support for Firebird, Microsoft SQL Server, Oracle, but not for PostgreSQL. This is the first reason. I really don't know how proper tiOPF is when we focuses on CGI development. At a first look, the project seemed to be very complex to use, but of course, I may be wrong.

tiOPF supports FPC's SQLDB and thus (in theory) all databases supported there. See also here: http://wiki.freepascal.org/tiOPF (listing in About)

Regards,
Sven

Reply by email

Graeme Geldenhuys
to Luciano de Souza: For desktop environments, there are mature projects on data persistance. Press Objects,…
Luciano de Souza wrote
What about CGI environments?

Simply use tiOPF for that too. We do, and it works perfectly. We share all our business objects and business rules between CGI and GUI Desktop apps, plus all that code is unit tested in the same test suite too.

Regards,   - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://fpgui.sourceforge.net

Reply by email

Graeme Geldenhuys
to Luciano de Souza: Actually, reading the tiOPF, I found the support for Firebird, Microsoft SQL Server,…
Luciano de Souza wrote
Actually, reading the tiOPF, I found the support for Firebird, Microsoft SQL Server, Oracle, but not for PostgreSQL.

tiOPF has a SqlDB (included with the Free Pascal Compiler) backend. As it stands (in the public repository), SqlDB support in tiOPF is more geared towards SqlDB+Firebird.

I already have a private branch where I refactored the SqlDB backend [which wasn't much work] to support PostgreSQL, MySQL etc. I never made that code public, because I haven't implemented the unit tests for those yet. I'll try and find some time this week to implement the tests suite and make that code public.

first look, the project seemed to be very complex to use, but of course, I may be wrong.

It's not really complex to use, it is just a new tool you need to learn (just like any other development tools or frameworks).

tiOPF has plenty of demos - which were designed to be very simplistic, to teach one simple thing at a time. It also has some "real world" style demos, which are more complex. There are lots of documentation. A very good history or knowledge base of information in the support newsgroups (I recommend you download them for offline searching - Mozilla Thunderbird works well). And if you still get stuck, simply post a message in the tiopf.support newsgroup.

Regards,   - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://fpgui.sourceforge.net

Reply by email