[fpc-pascal] Updated mysql units.

Cliff Baeseman Cliff.Baeseman at Greenheck.Com
Fri Apr 30 12:09:03 EDT 1999


This is great should make for easy integration into lazarus code.

;)

Cliff

-----Original Message-----
From: michael at wisa.be [mailto:michael at wisa.be]On Behalf Of Michael Van
Canneyt
Sent: Friday, April 30, 1999 10:44 AM
To: fpc-pascal at vekoll.saturnus.vein.hu
Cc: Lazarus project
Subject: RE: [fpc-pascal] Updated mysql units.




On Fri, 30 Apr 1999, Cliff Baeseman wrote:

> This will come in handy for lazarus in the future. I love mysql and intend
> to build the db components using it.

I have a TDatabaseManager working and functional, ready to be committed to
CVS (in the FCL).

It is a replacement for the BDE (which we all know and love so much :) )

It manages database types and associated queries, tables and stored procs.

At the bottom of this mail is the interface declaration;
from this it should be clear what I intend to do:

For each DB type (mysql, postgresql and interbase have FUNCTIONAL FPC units)
We declare 3 descendants from
  TDataset (possibly TSQLdataset)
and a descendant from TDatabase, that implement the specific issues for the
DB server: So Something like

  TMysqlDatabase= class(Tdatabase)
  TMysqlQuery= class(TSQLdataset)
  TMysqltable= class(TSQLdataset)
  TMysqlstoredproc= class(TSQLdataset)

Then you do a

DatabaseManager.RegisterDB('MySQL',TMySQLdatabase,TMySQLQuery,TMYSqlTable,TM
ySQLStoredProc,Params);
(params is a list with parameters needed to set up a connection,
 similar to the BDE alias stuff...)

After that, the DatabaseManager object takes care of creating database
classes,
queries etc. RIGHT IN YOUR PROGRAM !! no need for the BDE Administrator.
(although the object could be used to construct one :) )

It's still in embryonal form, but I have it pretty much thought out.
The TDatabaseManager class already works fine with dummy classes.

What I need to do now is to define the functionality of TDatabase and
TDataset
and TSQLdataset, so I can implement skeleton definitions. After that I will
commit the stuff.

I will probably use MySQL or interbase to work out the first classes.
(more likely MySQL, it is easier to work with...)

Interested people can contact me *IF* they want to help :-)

Michael.

TDatabaseManager class definition (to be enhanced still):
--------------------------8<-----------------------------

Type
 // Basic classes
 EDatabaseError = Class(Exception);

 TDataSet = Class(TComponent);    // Common dataset type
 TSQLDataset = Class(TDataSet);   // For SQL based databases (mysql,
Postgres, interbase)
 TQuery = Class (TSQLDataset);    // Common Query class
 TDatabase = Class (TComponent);  // Common Database class

 // Class references for basic classes
 TDataSetClass = Class of TDataset;
 TDatabaseClass = Class of TDatabase;

 TDatabaseRecord = Record
   Name : ShortString;
   DatabaseClass : TDatabaseClass;
   TableType,QueryType,StoredProcType : TDatasetClass;
   Params : TStrings;
   end;
 PDatabaseREcord = ^TDatabaseRecord;

 EDataBaseManagerError = Class(EDatabaseError);

 TDataBaseManager = Class (TComponent)
   Public
   Constructor Create (AOwner : TComponent);override;
   Destructor Destroy;override;
   Procedure RegisterDB (Const DBType : ShortString;
                           DBClass : TDatabaseClass;
                           DBTable,
                           DBQuery,
                           DBStoredProc : TDataSetClass;
                           DBParams : TStrings);
   Function  CompatibleQueryClass(DBClass : TDatabaseClass) : TDataSetClass;
   Function  CompatibleStoredProcClass(DBClass : TDatabaseClass) :
TDataSetClass;
   Function  CompatibleTableClass(DBClass : TDatabaseClass) : TDataSetClass;
   Procedure CreateDataBase (DBType : Shortstring;Var DB : TDatabase);
   Procedure CreateTable (DB : TDatabase; Var Table : TDataset);
   Procedure CreateQuery (DB : TDatabase; Var Query : TDataset);
   Procedure CreateStoredProc (DB : TDatabase; Var StoredProc : TDataset);
   // Properties
   Property DatabaseCount : Longint Read GetCount;
   Property Databases[Index : Longint] : ShortString Read GetDatabase;
   Property DataBaseType[Index : Longint] : TDatabaseClass Read
GetDatabaseClass;
   Property QueryType[Index : Longint] : TDatasetClass Read GetQueryClass;
   Property StoredProcType[Index : Longint] : TDatasetClass Read
GetStoredProcClass;
   Property TableType[Index : Longint] : TDatasetClass Read GetTableClass;
   end;

_________________________________________________________________
     To unsubscribe: mail lazarus-request at miraclec.com with
                "unsubscribe" as the Subject






More information about the Lazarus mailing list