Difference between revisions of "Lazarus DB Faq"

From Lazarus wiki
Jump to navigationJump to search
m (Text replace - "delphi>" to "syntaxhighlight>")
(Started linking to individual pages to remove duplicate content and make it clearer where to find things)
Line 3: Line 3:
 
== General ==
 
== General ==
  
This FAQ will be directed to database programming with Lazarus.
+
This FAQ covers database programming with Lazarus.
  
 
=== Where can I find more FAQ? ===
 
=== Where can I find more FAQ? ===
  
See the official website www.lazarus.freepascal.org. There is another FAQ as well. In [[Lazarus Faq]] you will find a page that once started as a copy of the FAQ from www.lazarus.freepascal.org .
+
See [[Lazarus Faq]]. See also the official website [http://www.lazarus.freepascal.org].
  
 
=== Where can I find database components? ===
 
=== Where can I find database components? ===
  
At the moment the SQLdb components are part of the Lazarus package, you only need to install them. If you look in the [$LazarusDir]/components you will see a subdirectory SQLdb. Install the sqldblaz.lpk and you will be able to connect to MySQL, Interbase / Firebird and Postgres servers.
+
At the moment the SQLdb components are part of FPC and Lazarus. They are installed by default in all more or less recent Lazarus versions.
Look at [[Install Packages]] for help on installing packages.
+
Manual installation: if you look in the [$LazarusDir]/components you will see a subdirectory SQLdb. Install the sqldblaz.lpk and you will be able to connect to MySQL, Interbase / Firebird, Postgres, MS SQL and Sybase ASE (if you have FPC 2.6.1+), Oracle servers.
 +
See [[Install Packages]] for help on installing packages.
  
 
=== Are there other components? ===
 
=== Are there other components? ===
 
+
* See [[Lazarus_Database_Tutorial]] for a list of what databases work with what components.
* [http://zeoslib.sourceforge.net/index.php ZEOS components] - have been ported to Lazarus as well.
 
You have to download ZEOSDBO_Rework from [http://sourceforge.net/cvs/?group_id=35994 ZEOS cvs].
 
See also this tutorial for [[Zeos_tutorial|Zeos]].
 
 
 
* [http://pdo.sourceforge.net Pascal Data Objects] - works equally with Delphi and FPC 2.0 (MySQL and Firebird)
 
 
 
* [http://sourceforge.net/projects/fibl/ FIBL] - FIBL is Sergey Smirnov's port of FreeIB by Greg Deatz. Works with Interbase and Firebird
 
 
 
* [http://www.progdigy.com/?page_id=5 Unified IB] - UnifiedIB - Works with Firebird
 
 
 
* [http://www.sybase.com/products/databasemanagement/advantagedatabaseserver/tdataset-descendant Advantage] - Advantage TDataSet Descendant.  Supports Advantage Database Server version 10.1 or greater.
 
  
 
== IB / FB ==
 
== IB / FB ==
 +
* Please see [[Firebird_in_action]]
  
=== How do I connect from Linux to a Windows server ===
 
Entering the correct path to a database on a Windows server from a Linux client is not very clear.
 
 
Say you have installed firebird in F:\Program Files\firebird\. The employee.fdb example database will then be installed in the directory F:\Program Files\firebird\examples\ . The IP-adress of your computer is 192.168.2.100.
 
 
Then entering the following databasename 
 
192.168.2.100:F:\Program Files\firebird\examples\employee.fdb
 
in your IBConnection will connect to the required database.
 
 
Note that you don't have to enter a value for the hostname property!
 
  
 
== MySQL ==
 
== MySQL ==
 +
* Please see [[mysql]]
  
=== Which version of mySQL is supported? ===
 
 
Currently MySQL 4.0, 4.1, 5.0 and 5.1 are supported by de SQLdb components. Make sure you are using the correct connection component for your client library version. So if you have the client libraries installed for MySQL 4.1 then you have to use TMySQL41Connection component, even if the server is running version 4.0 or 5.0.
 
  
 
==== Pascal Data Objects ====
 
==== Pascal Data Objects ====
Line 71: Line 50:
  
 
* [[Databases]]
 
* [[Databases]]
 +
* [[Lazarus_Database_Tutorial]]
  
 
[[Category:Databases]]
 
[[Category:Databases]]
 +
[[Category:FAQ]]
 +
[[Category:FPC]]
 +
[[Category:Lazarus]]

Revision as of 09:24, 14 September 2012

Deutsch (de) English (en) español (es) français (fr) italiano (it) 日本語 (ja) português (pt) русский (ru) slovenčina (sk) 中文(中国大陆)‎ (zh_CN)

General

This FAQ covers database programming with Lazarus.

Where can I find more FAQ?

See Lazarus Faq. See also the official website [1].

Where can I find database components?

At the moment the SQLdb components are part of FPC and Lazarus. They are installed by default in all more or less recent Lazarus versions. Manual installation: if you look in the [$LazarusDir]/components you will see a subdirectory SQLdb. Install the sqldblaz.lpk and you will be able to connect to MySQL, Interbase / Firebird, Postgres, MS SQL and Sybase ASE (if you have FPC 2.6.1+), Oracle servers. See Install Packages for help on installing packages.

Are there other components?

IB / FB


MySQL


Pascal Data Objects

There is now an alternative. The functions introduced with MySQL 4.1 and 5.0 like prepared statements, binding, and stored procedures are supported by database API called Pascal Data Objects, which is inspired by PHP Data Objects. All the code and documentation necessary to use this new API is available on sourceforge:

http://pdo.sourceforge.net

Jan 30, 2007: PDO has added drivers for Firebird 1.5 and 2.0

PostgreSQL

You can connect to PostgreSQL db by TPQConnection component. This component uses the PostgreSQL's libpq connection library [2], so you can easily connect almost every PostgreSQL db, but the component doesn't support the following connection options:

  • Port
  • ClientEncoding

Maybe there are other unsupported connection parameters.

The TPQConnection component does not directly support a Port property, but one can pass the port into the component via the Params parameter:

PQConnection.Params.Add('port=' + VariableContainingPort);

Also other connection parameters can be specified using Params property:

PQConnection.Params.Add('application_name=''yourappname''')

See also