Lazarus DB Faq
│
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?
- See Lazarus_Database_Tutorial for a list of what databases work with what components.
IB / FB
- Please see Firebird_in_action
MySQL
- Please see 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:
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''')