Recent

Author Topic: Any sort of Persistence class framework for Lazarus?  (Read 11956 times)

mdlueck

  • Jr. Member
  • **
  • Posts: 92
    • Lueck Data Systems
Any sort of Persistence class framework for Lazarus?
« on: July 29, 2011, 07:36:23 pm »
A co-worker developed for the Object Rexx language a Persistence class architecture to remove writing of SQL queries from code we were developing and build the appropriate SQL on-the-fly.

It was built as an abstract class, and required a subclass to be created where the wiring of fields / datatypes took place, and nothing further.

I contributed to the effort the ability to join multiple tables together introducing JOIN statements to their architecture.

I am poised to start developing a client / server app with a MS SQL Server 2008 back-end and looks to be involving roughly 50 tables. Being new to Pascal, I do not think I can justify going off and creating a Persistence class architecture on my own.

Does something similar already exist for use with Lazarus?

I am thinking to at least ask… back in 2005 I envisioned a client/server Object Rexx RAD environment… barrowing RAD design from Borland’s Delphi, cross platform, OSS/FS. Unfortunately Object Rexx is still not ready enough… progress has been made in the language, but according to one core developer, “still not ready yet.”

Lazarus looks to me like a good realization of that vision. So setting off to learn Pascal.

P.S. It made use of Object Rexx's ability to dynamical create methods in classes on-the-fly. Getters / setters were defined on-the-fly perfectly matching up to the schema defined in the subclass to the abstract Persistence class.

It was also making use of Rexx’s interpret silver-bullet keyword… to build Rexx code on-the-fly and then execute it.  ;D

« Last Edit: July 29, 2011, 07:42:28 pm by mdlueck »
--
Michael Lueck
Lueck Data Systems
http://www.lueckdatasystems.com/

jctaborda

  • New Member
  • *
  • Posts: 21
Re: Any sort of Persistence class framework for Lazarus?
« Reply #1 on: July 29, 2011, 10:10:22 pm »
Hi mdlueck,

Take a look at tiopf. http://tiopf.sourceforge.net/

You can use the data dictionary tool from lazarus to create object classes and most of the code needed to create, read, update and save objects and lists of objects.

Hope it helps
Hospital Nacional de Clínicas
Universidad Nacional de Córdoba
www.unc.edu.ar

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

mdlueck

  • Jr. Member
  • **
  • Posts: 92
    • Lueck Data Systems
Re: Any sort of Persistence class framework for Lazarus?
« Reply #3 on: July 30, 2011, 07:30:10 pm »
Very slick! Thank you both!
--
Michael Lueck
Lueck Data Systems
http://www.lueckdatasystems.com/

mdlueck

  • Jr. Member
  • **
  • Posts: 92
    • Lueck Data Systems
Re: Any sort of Persistence class framework for Lazarus?
« Reply #4 on: August 01, 2011, 02:39:14 pm »
Two questions, posted here as I am unable to connect to the tiOPF Support, I believe due to the odd port 8080.

1) I see listed that the SQL Server support is via "MSSQLServer via ADO". From the Lazarus DB pages, I never saw ADO listed. So is connecting via ADO preferable / reliable? I was aware of Zeoslib as a connection option to SQL Server: http://wiki.lazarus.freepascal.org/Lazarus_Database_Tutorial#Lazarus_and_MSSQL and I believe one of the other Lazarus drivers. I had not seen on other pages ADO even listed as a database connection type to use with Lazarus.

2) So the standard Lazarus DB controls... will they work with this Persistence class architecture? I cannot get a good indication what changes in how one develops client/server DB front ends if I add this Persistence class architecture to the configuration. Listed are tiopf database controls for Delphi, but Lazarus does not appear to be mentioned... or was it that Delphi controls needed to be replaced with alternate controls and Lazarus controls work with the Persistence class architecture?

TIA!
--
Michael Lueck
Lueck Data Systems
http://www.lueckdatasystems.com/

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 7500
Re: Any sort of Persistence class framework for Lazarus?
« Reply #5 on: August 01, 2011, 05:57:47 pm »
Two questions, posted here as I am unable to connect to the tiOPF Support, I believe due to the odd port 8080.

1) I see listed that the SQL Server support is via "MSSQLServer via ADO". From the Lazarus DB pages, I never saw ADO listed. So is connecting via ADO preferable / reliable? I was aware of Zeoslib as a connection option to SQL Server: http://wiki.lazarus.freepascal.org/Lazarus_Database_Tutorial#Lazarus_and_MSSQL and I believe one of the other Lazarus drivers. I had not seen on other pages ADO even listed as a database connection type to use with Lazarus.

1) Afaik ZEOS does not support ADO on Lazarus because the relevant oledb headers are missing
2) afaik the only connection to mssql is via ODBC.

Quote
2) So the standard Lazarus DB controls... will they work with this Persistence class architecture? I cannot get a good indication what changes in how one develops client/server DB front ends if I add this Persistence class architecture to the configuration. Listed are tiopf database controls for Delphi, but Lazarus does not appear to be mentioned... or was it that Delphi controls needed to be replaced with alternate controls and Lazarus controls work with the Persistence class architecture?

Such specialistic questions must be directed to tiopf directly.
 

mdlueck

  • Jr. Member
  • **
  • Posts: 92
    • Lueck Data Systems
Re: Any sort of Persistence class framework for Lazarus?
« Reply #6 on: August 01, 2011, 06:24:50 pm »
2) afaik the only connection to mssql is via ODBC.

Would that be the "MSSQLServer via ADO" mentioned on the tiOPF site, or something else? Does ODBC = ADO?

Thanks!
--
Michael Lueck
Lueck Data Systems
http://www.lueckdatasystems.com/

jctaborda

  • New Member
  • *
  • Posts: 21
Re: Any sort of Persistence class framework for Lazarus?
« Reply #7 on: August 01, 2011, 09:31:29 pm »
Hi,

tiOPF can be used by lazarus and delphi, thus the reference to ado.
I saw people using zeos to connect to databases but I never used it with MSSQL so can't comment on that.

For the user interface you can use the MGM pattern (Model GUI Mediator).
Basically you use normal controls and create a relationship between the model and the components.

uses tiBaseMediator......;

.....

 FMediator := TFormMediator.Create(Self);
    FMediator.AddProperty('Name', txtName);
    ....
    FMediator.Subject:= MyClient;
    FMediator.Active := True;

There are mediators for many common controls.

When you load an object, its properties value are displayed in the controls and every change you make are reflected to the underlaying object.

You validate data in the isValid method and if there is an error in your input, for example the color of the edit box changes.

There is a sample app included in tiopf/source/demos/lcl/Demo_21_AddressBook

Hope it helps a bit.
Hospital Nacional de Clínicas
Universidad Nacional de Córdoba
www.unc.edu.ar

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 7500
Re: Any sort of Persistence class framework for Lazarus?
« Reply #8 on: August 01, 2011, 10:24:21 pm »
2) afaik the only connection to mssql is via ODBC.

Would that be the "MSSQLServer via ADO" mentioned on the tiOPF site, or something else? Does ODBC = ADO?

No that is not via ADO and ODBC is not ADO.

The ADO option mentioned IS available for ZEOS, but NOT for ZEOS with FPC.

Lacak2

  • Guest
Re: Any sort of Persistence class framework for Lazarus?
« Reply #9 on: August 02, 2011, 08:24:13 am »
2) afaik the only connection to mssql is via ODBC.
Yes ATM it is true.
But there is already registered in bug tracker new connection component special for MS SQL Server (and potentially also for Sybase servers)
It uses corss-platrform FreeTDS db-library or Microsoft Client DB-Library (ntwdblib.dll)
http://bugs.freepascal.org/view.php?id=17303

mdlueck

  • Jr. Member
  • **
  • Posts: 92
    • Lueck Data Systems
Re: Any sort of Persistence class framework for Lazarus?
« Reply #10 on: August 02, 2011, 04:55:07 pm »
No that is not via ADO and ODBC is not ADO.

The ADO option mentioned IS available for ZEOS, but NOT for ZEOS with FPC.

All right, thank you for the clarification.

So I understand that "whatever" an ADO connection to SQL Server is, it is NOT the ODBC driver.

And ZEOS is not currently an option with FPC.

So what exactly is this "ADO" connection which is an option with FPC / Lazarus? Where do I see it / poke a stick at it?

What sort of installation requirements will the target computers have in order to run my Lazarus program which needs to access SQL Server?

I am thinking to hard code in the ID/pw for the database, have an Auth table inside the database my applicaiton uses, simply obtain the UserID from Windows, look up that ID in the Auth table, if found grant access based on the PermMask of the matching record found in the Auth table. If no matching record is found, grant no access and display a message instructing to visit someone with Auth Granting permissions.
--
Michael Lueck
Lueck Data Systems
http://www.lueckdatasystems.com/

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Any sort of Persistence class framework for Lazarus?
« Reply #11 on: August 02, 2011, 06:07:21 pm »
mdlueck, if you're using SQL server, look into trusted authentication (there's another name for it that I forgot): this logs you onto the SQL server with your Active Directory (Windows) username.

Never heard about ADO support for FreePascal.
ADO could be http://en.wikipedia.org/wiki/ActiveX_Data_Objects, or it may mean ADO.Net, a newer version. I don't know.

I'd really suggest you get in touch with Graeme Geldenhuys (tiOPF maintainer for FPC) via the tiOPF newsgroup server.
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

mdlueck

  • Jr. Member
  • **
  • Posts: 92
    • Lueck Data Systems
Re: Any sort of Persistence class framework for Lazarus?
« Reply #12 on: August 02, 2011, 06:54:06 pm »
Thanks much, BigChimp.

(Puzzled look on my face...) Lazarus IS able to natively attache to SQL Server, correct? (Aside from the tiOPF framework)

I would think at the very least native Lazarus could connect to it via the ODBC driver.

I am new to dealing with SQL Server, coming from a DB2 and MySQL background.
--
Michael Lueck
Lueck Data Systems
http://www.lueckdatasystems.com/

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Any sort of Persistence class framework for Lazarus?
« Reply #13 on: August 02, 2011, 06:58:42 pm »
Yeah, it works through ODBC, using the native sqldb components (have only written a small test app myself, but it works).

Actually, I'm interested in connecting to DB2 myself - so I'll probably go looking into connecting to DB2 LUW using ODBC...

PS: Do you happen to be an AS/400 guy by any chance? REXX+DB2=AS/400 or maybe mainframe???
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

mdlueck

  • Jr. Member
  • **
  • Posts: 92
    • Lueck Data Systems
Re: Any sort of Persistence class framework for Lazarus?
« Reply #14 on: August 02, 2011, 07:17:00 pm »
PS: Do you happen to be an AS/400 guy by any chance? REXX+DB2=AS/400 or maybe mainframe???

DB2 Common Server, later renamed Universal Database. I have worked with it on OS/2, Windows, and open to trying it on Linux, versions since 2.x.

DB2/400 was a totally different animal, needed the... DRDA <sp?> software to connect to such servers from a PC client. DB2 on 400 was quite similar to DB2 on the mainframe, where DB2 Common Server was quite similar on Common Server platforms.

As for Rexx, there again "Common Server" platforms... OS/2, Windows, and Linux. Classic Rexx on OS/2, Object Rexx since 1.0.3.0, currently ooRexx 4.1.
--
Michael Lueck
Lueck Data Systems
http://www.lueckdatasystems.com/