[lazarus] Lazarus with Mysql again

Michael Van Canneyt michael.vancanneyt at wisa.be
Mon May 5 13:34:26 EDT 2003




On Mon, 5 May 2003, Tony Maro wrote:

> Rafael A. wrote:
>
> >Does anybody here know where I can find a good tutorial where I can learn
> >about Lazarus (Free Pascal) with Mysql???
> >
> >
> I'll second that...  I originally was going to write CBT to support
> MySQL and junked the idea when I never could figure out how to use the
> MySQL units.

I am amazed at the amount of trouble people seem to have with this subject.
Currently, the DB situation of FPC is as follows:

- Low level access (i.e. straight API header translation) to
  MySQL (3.23 and 4.0)
  Oracle
  Interbase/Firebird
  PostgreSQL
  ODBC (Linux and Windows)

The units for this can be found in packages/base in the FPC source tree,
test programs are provided, I've tested all of them myself.

- Then there are TDataset descendent implementations in the FCL for
  MySQL
  Interbase
  DBase
  Flat-file
  They all work definitely read-only, but could use more testing.

  In the FCL, there is also a simple OOP wrapper around the ODBC layer.

Now, since these implementations depend on the low-level access units, it is wise to
take the low-level test programs and see whether that works. (Independent of Lazarus,
don't use any GUI) Only then you should start using the TDataset implementation.

The case for (or against) MYSQL is a bit tricky: Unfortunately the MySQL people
change their API in incompatible ways from one version to the next. They can
mask this for C application programmers with some macro magic, but that does
not work for Pascal, obviously.

It is therefore IMPERATIVE that the version reported by
- Client library
- MySQL Server
- the 'mysql_version' unit
match EXACTLY. That means: 3.23 <> 3.22 !

Failure to meet this requirement will result in inexplicable crashes, stack corruptions
etc.

It is for this reason that for any serious database development in FPC/Lazarus,
I currently recommend against using MySQL. If you absolutely must connect to
MySQL, try the ODBC driver, it should hide all the API horrors.

If you don't like this idea (I wouldn't use ODBC myself), and you're not tied
to MySQL, try using Interbase.
Its free counterpart Firebird (http://www.firebirdsql.org) is very stable,
and offers MUCH more functionality as MySQL. And: it is supported by FPC.

I use it myself, in commercial projects for huge databases, so rest
convinced that it works OK.

Michael.








More information about the Lazarus mailing list