Lazarus DB Faq
This FAQ covers database programming with Lazarus.
Where can I find more FAQ?
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
- 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
You can connect to PostgreSQL db by TPQConnection component. This component uses the PostgreSQL's libpq connection library , so you can easily connect almost every PostgreSQL db, but the component doesn't support the following connection options:
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: